MVP_Harry's blog

By MVP_Harry, history, 21 month(s) ago, In English

Hey there,

Two and a half years ago, I started doing CP, and it's a very fun and meaningful experience that I will cherish. But at some point, I just started growing tired of it (perhaps because I wasn't improving that much anymore), and I also realized that the computer science world is way larger than just CP.

So... what's after CP? What did you do after you "retired" from CP? Which area of CS did you explore?

I'm genuinely a bit lost and don't know what to do. For the past 6 months or so, I tried exploring stuff like Machine Learning, Computer Theory, and topics closer to theoretical CS, but felt like I wasn't making much progress without a teacher or a "partner" that could help me when I'm stuck (on that note, should I cold email university professors for research/learning opportunities?) I also don't know any stuff related to "developing" — I tried writing a chess engine in c++ and was also stuck, and I don't really know any of the programming languages that well.

For some context, I'm a high school rising senior living in the US. What should I do?

Thanks :)

Full text and comments »

  • Vote: I like it
  • +104
  • Vote: I do not like it

By MVP_Harry, history, 2 years ago, In English

Hi there,

As you can see in my rating graph, I used to be a candidate master. However, since I reached my peak, my performance has dropped significantly. I had to admit that it was probably my fault, as I stopped training as hard as before.

Recently, I did horribly in the December USACO Plat. contest. Then, I proceed to absolutely bomb the next three CF rounds I participated (including today's Div. 2). Not only was I unable to solve the harder problems (D and E), I had trouble in solving C.

I'm very sad right now and I hope to seek some help from you. How should I train in the next month to get back to candidate master? I will definitely do more problems, but what strategy should I use? Should I start from 1800-1900ish problems? (Previously I've done 2100-2200+ problems in my training, but since I wasn't as good as before, should I "restart"?)

Thanks. :(

Full text and comments »

  • Vote: I like it
  • +26
  • Vote: I do not like it

By MVP_Harry, history, 3 years ago, In English

Hi, I was solving this year's Baltic OI problems, and I was stuck on Day 1 Problem 2 — Servers. I looked at the solution from here, but the explanation for the last task is too vague for me to understand.

My current progress

Can you please help me? Thanks :)

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

By MVP_Harry, history, 3 years ago, In English

Hi,

About three weeks ago, I asked a related question here. In that post, my program output to stdout, while it needs to be output into a file. A lot of people gives me suggestions to use freopen("Filename.in", "r", stdin); freopen("Filename.out", "w", stdout); instead of ifstream ...

That's what I did and things have been ok for the past three weeks. However, when I tried to submit a solution using freopen, this happens:

freopen

I go check my solution and find no error that would cause "runtime error or memory limited exceeded". Therefore, I submitted it again, only replacing freopen with ifstream. Then, it gets accepted:

ifstream.

This might be a noobish question, but what causes this and how can I avoid that? Thank you!

P.S. This is the code:

#include<bits/stdc++.h>
#define ll long long
#define rep(i, m, n) for (int i = m; i <= n; i++)
#define per(i, m, n) for (int i = m; i >= n; i--)
#define FOR(i, m, n, k) for (int i = m; i <= n; i += k)
#define ROF(i, m, n, k) for (int i = m; i >= n; i -= k)
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define INF 0x3f3f3f3f
using namespace std;

const int maxn = 3e4 + 10;

struct edge {
    int to, cost;
};

int N, T;
int a[105][105], dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
int dis[maxn];
vector<edge> G[maxn];

int get(int x, int y, int t) {
    return (x - 1) * N + y + t * N * N;
}

void dijkstra(int s) {
    priority_queue<pii, vector<pii>, greater<pii> > q;
    memset(dis, INF, sizeof(dis));
    dis[s] = 0;
    q.push(make_pair(0, s));
    while (!q.empty()) {
        pii p = q.top();
        q.pop();
        int u = p.second;
        if (dis[u] < p.first) continue;
        for (auto node : G[u]) {
            int v = node.to;
            if (dis[v] > dis[u] + node.cost) {
                dis[v] = dis[u] + node.cost;
                q.push(make_pair(dis[v], v));
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    // ifstream cin("visitfj.in");
    // ofstream cout("visitfj.out");
    freopen("visistfj.in", "r", stdin);
    freopen("visistfj.out", "w", stdout);
    cin >> N >> T;
    rep(i, 1, N) rep(j, 1, N) cin >> a[i][j];
    rep(i, 1, N) {
        rep(j, 1, N) {
            rep(k, 0, 3) {
                int x = i + dx[k], y = j + dy[k];
                if (x < 1 || x > N || y < 1 || y > N) continue;
                rep(t, 0, 2) {
                    int nxt = (t + 1) % 3;
                    int cost = T + ((nxt == 0) ? a[x][y] : 0);
                    G[get(i, j, t)].pb((edge) {get(x, y, nxt), cost});
                }
            }
        }
    }
    dijkstra(get(1, 1, 0));
    int ans = INF;
    rep(i, 0, 2) ans = min(dis[get(N, N, i)], ans);
    cout << ans << "\n";
    return 0;
}

Full text and comments »

  • Vote: I like it
  • -25
  • Vote: I do not like it

By MVP_Harry, history, 3 years ago, In English

Are there any metalhead in Codeforces? What's your favorite band/album for each genre?

Here's my answer:

  • Heavy Metal

Band: Iron Maiden/Judas Priest/Black Sabbath

Album: Painkiller (Judas Priest)/Paranoid (Black Sabbath)

  • Thrash Metal

Band: Megadeth!

Album: Rust in Peace (Megadeth)/Ride the Lightening (Metallica)

  • Black Metal

Band: Emperor

Album: Ugh this is tough... I'll choose five

(1) Anthems to the Welkin at Dusk (Emperor)

(2) Storm of the Light's Bane (Dissection)

(3) Filosofem (Burzum)

(4) 孤雁 (葬尸湖) This is a Chinese Black Metal Band — it's awesome, give it a try if you haven't.

(5) Souvenirs D'un Autre Monde (Alcest) Alcest is more like a shoegaze/post-black-metal band, but it's still extremely good!

  • Death Metal

Band: Death

Album: Symbolic (Death)

I don't really listen to death metal.

At last, PM me if you are interested, maybe we can discuss more!

Full text and comments »

  • Vote: I like it
  • -6
  • Vote: I do not like it

By MVP_Harry, history, 3 years ago, In English

Edit: Problem fixed. It turns out that I output the answer in a separate function before I input and output the file, which causes the problem. Thanks for everyone that helps :)

Edit: I did write output file

Here

I've been doing some past USACO Gold problems lately, but I have met some troubles regarding submission. Although my program outputs the correct answer, it keeps telling me that the answer is incorrect. I've met these kind of troubles before, so I thought its just a format issue. But no matter how I adjust the way I output the answer, it doesn't work.

For example, I have tried cout << ans << "\n"; cout << ans << endl; cout << ans << " "; cout << ans; but non of them works.

Here are two screenshots:

USACO 2015 G DEC USACO 2016 G JAN

Can someone please help me with that? I just don't want to run into these kind of troubles during real contest lol. Thanks!

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By MVP_Harry, history, 3 years ago, In English

Hi Codeforces,

The first round of USACO is probably going to start within a month. I am currently a sophomore in high school and I wish to enter Platinum division this time. I'm pretty confident that I can enter Gold division, but I am still uncertain in how to train more effectively so that I can achieve my goal.

So here is the thing, a lot of experienced people suggest that the best way to practice is to do a lot of random problems on CF with suitable ratings. I have been training that way for a while, and I can now solve most of the problems from 1700 — 1800.

However, is doing random problems really helpful for USACO performances? Because OI is still quite different from CF problems, and most of the USACO Gold problems are among DP, Graph Theory (short paths, MST etc.) and sometimes Data Structure and Strings (at least that's what I think). So I also made several problem lists on those topics which consists of many past gold problems. But I found my training process to progress more slowly, and I wonder if that's the right strategy to practice?

Can anyone also share their strategy to enter Platinum division? Thanks :)

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

By MVP_Harry, history, 3 years ago, In English

Hi Codeforces,

I am now switching to spacemacs as my text editor. It combines some main features of vim and emacs, which makes it very powerful. However, my main concern is how to compile and run the program efficiently. Right now, I have to manually compile the program in terminal using commands like g++ -o test test.cpp and ./test, which takes a lot of time. The previous text editors I used such as sublime text or vim can allow me to create custom shortcuts such as F9 to compile and run the program, but how can I do that in spacemacs?

Sorry if this is a trivial question, but it would be very helpful if you can answer this question :)

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it