Submission #72592

#TimeUsernameProblemLanguageResultExecution timeMemory
72592vexGame (IOI14_game)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define n 1505 using namespace std; int n; int sz[maxn],p[maxn]; int uk=0; void initialize(int N) { n=N; for(int i=0;i<n;i++) { sz[i]=1; p[i]=i; } } int fnd(int x) { if(x==p[x])return x; p[x]=fnd(p[x]); return p[x]; } bool same(int x,int y) { return fnd(x)==fnd(y); } void unite(int x,int y) { x=fnd(x); y=fnd(y); if(sz[x]<sz[y])swap(x,y); sz[x]+=sz[y]; p[y]=x; } int hasEdge(int u,int v) { if(same(u,v))return 0; u=fnd(u); v=fnd(v); if(sz[u]+sz[v]<n) { unite(u,v); return 1; } return 0; }

Compilation message (stderr)

game.cpp:2:11: error: expected unqualified-id before numeric constant
 #define n 1505
           ^
game.cpp:5:5: note: in expansion of macro 'n'
 int n;
     ^
game.cpp:6:8: error: 'maxn' was not declared in this scope
 int sz[maxn],p[maxn];
        ^~~~
game.cpp:6:8: note: suggested alternative: 'tan'
 int sz[maxn],p[maxn];
        ^~~~
        tan
game.cpp:6:16: error: 'maxn' was not declared in this scope
 int sz[maxn],p[maxn];
                ^~~~
game.cpp:6:16: note: suggested alternative: 'tan'
 int sz[maxn],p[maxn];
                ^~~~
                tan
game.cpp: In function 'void initialize(int)':
game.cpp:10:7: error: lvalue required as left operand of assignment
     n=N;
       ^
game.cpp:13:9: error: 'sz' was not declared in this scope
         sz[i]=1;
         ^~
game.cpp:14:9: error: 'p' was not declared in this scope
         p[i]=i;
         ^
game.cpp: In function 'int fnd(int)':
game.cpp:19:11: error: 'p' was not declared in this scope
     if(x==p[x])return x;
           ^
game.cpp:20:5: error: 'p' was not declared in this scope
     p[x]=fnd(p[x]);
     ^
game.cpp: In function 'void unite(int, int)':
game.cpp:31:8: error: 'sz' was not declared in this scope
     if(sz[x]<sz[y])swap(x,y);
        ^~
game.cpp:32:5: error: 'sz' was not declared in this scope
     sz[x]+=sz[y];
     ^~
game.cpp:33:5: error: 'p' was not declared in this scope
     p[y]=x;
     ^
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:43:8: error: 'sz' was not declared in this scope
     if(sz[u]+sz[v]<n)
        ^~