Submission #300999

#TimeUsernameProblemLanguageResultExecution timeMemory
300999ElyesChaabouniConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h" #include <bits/stdc++.h> int anc[200000], anc1[200000]; void get_anc(int x) { int cu=anc[x]; while(cu!=anc[cu]) cu=anc[cu]; anc[x]=cu; } void unite(int x, int y) { get_anc(x); get_anc(y); anc[anc[y]]=anc[x]; anc[y]=anc[x]; } void get_anc1(int x) { int cu=anc1[x]; while(cu!=anc1[cu]) cu=anc1[cu]; anc1[x]=cu; } void unite1(int x, int y) { get_anc1(x); get_anc1(y); anc1[anc1[y]]=anc1[x]; anc1[y]=anc1[x]; } int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> ans; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } for(int i = 0; i < n; i++) for(int j 0; j < n; j++) ans[i][j]=0; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j]==1) unite(x, y); } } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if((get_anc(i)==get_anc(j) && p[i][j]!=1 )||(get_anc(i)!=get_anc(j) && p[i][j]==1 )) return 0; if(p[i][j]==3) return 0; } } for(int i = 0; i < n; i++) { vector<int>v; for(int j = 0; j < n; j++) { if(anc[j]==i) v.push_back(j); } for(int j = 0; j < (int)(v.size())-1; j++) { ans[v[j]][v[j+1]]=1; ans[v[j+1]][v[j]]=1; } } for(int i = ; i < n; i++) anc1[j]=-1; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j]==2) { unite1(get_anc(i), get_anc(j)); } } } for(int i = 0; i < n; i++) { vector<int>v; for(int j = 0; j < n; j++) { if(anc1[j]==i) v.push_back(j); } for(int j = 0; j < (int)(v.size())-1; j++) { ans[v[j]][v[j+1]]=1; ans[v[j+1]][v[j]]=1; } if(v.size() == 2) return 0; ans[v[0]][v[n-1]]=1; ans[v[n-1]][v[0]]=1; } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:39:3: error: 'answer' was not declared in this scope
   39 |   answer.push_back(row);
      |   ^~~~~~
supertrees.cpp:42:12: error: expected ';' before numeric constant
   42 |   for(int j  0; j < n; j++)
      |            ^ ~
      |            ;
supertrees.cpp:42:19: warning: for increment expression has no effect [-Wunused-value]
   42 |   for(int j  0; j < n; j++)
      |                 ~~^~~
supertrees.cpp:42:22: error: expected ')' before ';' token
   42 |   for(int j  0; j < n; j++)
      |      ~               ^
      |                      )
supertrees.cpp:42:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   42 |   for(int j  0; j < n; j++)
      |   ^~~
supertrees.cpp:42:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |   for(int j  0; j < n; j++)
      |                        ^
supertrees.cpp:41:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   41 |  for(int i = 0; i < n; i++)
      |  ^~~
supertrees.cpp:42:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |   for(int j  0; j < n; j++)
      |                        ^
supertrees.cpp:42:24: error: 'j' was not declared in this scope
supertrees.cpp:49:11: error: 'x' was not declared in this scope
   49 |     unite(x, y);
      |           ^
supertrees.cpp:49:14: error: 'y' was not declared in this scope
   49 |     unite(x, y);
      |              ^
supertrees.cpp:56:18: error: invalid operands of types 'void' and 'void' to binary 'operator=='
   56 |    if((get_anc(i)==get_anc(j) && p[i][j]!=1 )||(get_anc(i)!=get_anc(j) && p[i][j]==1 ))
      |        ~~~~~~~~~~^~~~~~~~~~~~
      |               |           |
      |               void        void
supertrees.cpp:56:59: error: invalid operands of types 'void' and 'void' to binary 'operator!='
   56 |    if((get_anc(i)==get_anc(j) && p[i][j]!=1 )||(get_anc(i)!=get_anc(j) && p[i][j]==1 ))
      |                                                 ~~~~~~~~~~^~~~~~~~~~~~
      |                                                        |           |
      |                                                        void        void
supertrees.cpp:64:3: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   64 |   vector<int>v;
      |   ^~~~~~
      |   std::vector
In file included from /usr/include/c++/9/vector:67,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:386:11: note: 'std::vector' declared here
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
supertrees.cpp:64:10: error: expected primary-expression before 'int'
   64 |   vector<int>v;
      |          ^~~
supertrees.cpp:68:5: error: 'v' was not declared in this scope
   68 |     v.push_back(j);
      |     ^
supertrees.cpp:70:28: error: 'v' was not declared in this scope
   70 |   for(int j = 0; j < (int)(v.size())-1; j++)
      |                            ^
supertrees.cpp:76:14: error: expected primary-expression before ';' token
   76 |  for(int i = ; i < n; i++)
      |              ^
supertrees.cpp:84:34: error: invalid use of void expression
   84 |     unite1(get_anc(i), get_anc(j));
      |                                  ^
supertrees.cpp:90:3: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   90 |   vector<int>v;
      |   ^~~~~~
      |   std::vector
In file included from /usr/include/c++/9/vector:67,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:386:11: note: 'std::vector' declared here
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
supertrees.cpp:90:10: error: expected primary-expression before 'int'
   90 |   vector<int>v;
      |          ^~~
supertrees.cpp:94:5: error: 'v' was not declared in this scope
   94 |     v.push_back(j);
      |     ^
supertrees.cpp:96:28: error: 'v' was not declared in this scope
   96 |   for(int j = 0; j < (int)(v.size())-1; j++)
      |                            ^
supertrees.cpp:101:6: error: 'v' was not declared in this scope
  101 |   if(v.size() == 2)
      |      ^
supertrees.cpp:103:7: error: 'v' was not declared in this scope
  103 |   ans[v[0]][v[n-1]]=1;
      |       ^