Submission #746174

#TimeUsernameProblemLanguageResultExecution timeMemory
746174mnbvcxz123Game (IOI14_game)C++17
Compilation error
0 ms0 KiB
int n; int g[1505][1505]; struct DSU{ int p[1505]; void init(){memset(p,-1,sizeof(p));} int find(int x){ if(p[x]<0)return x; return p[x]=find(p[x]); } void unite(int a, int b){ a=find(a); b=find(b); if(a==b)return; p[a]+=p[b]; p[b]=a; } int get(int x){return -p[find(x)];} }dsu; void initialize(int N){ n=N; dsu.init(); } int has_Edge(int a, int b){ a=dsu.find(a); b=dsu.find(b); ++g[a][b],++g[b][a]; if(g[a][b]==dsu.get(a)*dsu.get(b)){ dsu.unite(a,b); for(int i=0;i<n;++i){ g[a][i]+=g[b][i]; g[i][a]+=g[i][b]; } return 1; } return 0; }

Compilation message (stderr)

game.cpp: In member function 'void DSU::init()':
game.cpp:6:14: error: 'memset' was not declared in this scope
    6 |  void init(){memset(p,-1,sizeof(p));}
      |              ^~~~~~
game.cpp:1:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
  +++ |+#include <cstring>
    1 | int n;