Comments

seems that I used flush for debug usage. Better remove it by this comment

sorry that I've not been here for a long time and didn't notice your post. Here's the code of problem B.

#include <iostream>
#include <cstring>
using namespace std;
int stu[1002];
bool t[1002];
int main()
{
    int cur, n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> stu[i];
    for (int i = 1; i <= n; ++i) {
        memset(t, 0, sizeof(t));
        cur = i;
        while (t[cur] == false) {
            t[cur] = true;
            cur = stu[cur];
        }
        cout << cur << ' ' << flush;
    }
    return 0;
}

Thanks, that helps a lot!

But I am still wondering why it behaves different from the C++ Standards which refers here(cppreference.com) when using GNU C++(v5.1.0).

int       abs( int n );
long      abs( long n );
long long abs( long long n );
		(since C++11)

Is it a BUG of the compiler? And why this happens only when the result is very big?

Hello there, I'm new to Codeforces. Few days ago I tried to take part in this contest as my first one. When the contest is finished, I checked my code again but couldn't find any problem, so I asked my friend to help with me but we found that with different compiler selected, the result is different. Why and is it unfair?

The following pictures shows that the result of same file submitted with different compiler.  My code could be viewed/download here