Submission #756324

#TimeUsernameProblemLanguageResultExecution timeMemory
756324TrumlingConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
bool dfs1(int start,int beg) { vis[start]=1; for(int i=0;i<nn;i++) if(g[start][i]!=g[beg][i] && i!=start && i!=beg) return 0; for(int i=0;i<nn;i++) if(!vis[i] && g[start][i]==1) { ans[i][start]=1; ans[start][i]=1; return dfs1(i,beg); } vis[beg]=0; return 1; } bool dfs2(int start,int beg) { vis[start]=1; for(int i=0;i<nn;i++) if(g[start][i]!=g[beg][i] && i!=start && i!=beg) return 0; //ll count=0; //for(int i=0;i<nn;i++) //if(g[start][i]==2) //count++; //if(count==1) //return 0; for(int i=0;i<nn;i++) if(!vis[i] && g[start][i]==2) { ans[i][start]=1; ans[start][i]=1; return dfs2(i,beg); } ans[start][beg]=1; ans[beg][start]=1; return 1; } int construct(vector<vector<int>> pr) { nn=pr.size(); g=pr; ans.assign(nn,vector<int>(nn,0)); for(int i=0;i<nn;i++) { bool now=dfs1(i,i); if(!now) return 0; } for(int i=0;i<nn;i++) { if(vis[i]) continue; bool now=dfs2(i,i); if(!now) return 0; } for(int i=0;i<nn;i++) ans[i][i]=0; build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'bool dfs1(int, int)':
supertrees.cpp:4:2: error: 'vis' was not declared in this scope
    4 |  vis[start]=1;
      |  ^~~
supertrees.cpp:5:16: error: 'nn' was not declared in this scope
    5 |  for(int i=0;i<nn;i++)
      |                ^~
supertrees.cpp:6:6: error: 'g' was not declared in this scope
    6 |   if(g[start][i]!=g[beg][i] && i!=start && i!=beg)
      |      ^
supertrees.cpp:9:16: error: 'nn' was not declared in this scope
    9 |  for(int i=0;i<nn;i++)
      |                ^~
supertrees.cpp:10:17: error: 'g' was not declared in this scope
   10 |   if(!vis[i] && g[start][i]==1)
      |                 ^
supertrees.cpp:12:4: error: 'ans' was not declared in this scope
   12 |    ans[i][start]=1;
      |    ^~~
supertrees.cpp: In function 'bool dfs2(int, int)':
supertrees.cpp:24:2: error: 'vis' was not declared in this scope
   24 |  vis[start]=1;
      |  ^~~
supertrees.cpp:26:16: error: 'nn' was not declared in this scope
   26 |  for(int i=0;i<nn;i++)
      |                ^~
supertrees.cpp:27:6: error: 'g' was not declared in this scope
   27 |   if(g[start][i]!=g[beg][i] && i!=start && i!=beg)
      |      ^
supertrees.cpp:40:16: error: 'nn' was not declared in this scope
   40 |  for(int i=0;i<nn;i++)
      |                ^~
supertrees.cpp:41:17: error: 'g' was not declared in this scope
   41 |   if(!vis[i] && g[start][i]==2)
      |                 ^
supertrees.cpp:43:4: error: 'ans' was not declared in this scope
   43 |    ans[i][start]=1;
      |    ^~~
supertrees.cpp:48:2: error: 'ans' was not declared in this scope
   48 |  ans[start][beg]=1;
      |  ^~~
supertrees.cpp: At global scope:
supertrees.cpp:53:15: error: 'vector' was not declared in this scope
   53 | int construct(vector<vector<int>> pr)
      |               ^~~~~~
supertrees.cpp:53:22: error: 'vector' was not declared in this scope
   53 | int construct(vector<vector<int>> pr)
      |                      ^~~~~~
supertrees.cpp:53:29: error: expected primary-expression before 'int'
   53 | int construct(vector<vector<int>> pr)
      |                             ^~~