Submission #309396

#TimeUsernameProblemLanguageResultExecution timeMemory
309396pere_gilConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #include "supertrees.h" using namespace std; int pos[1000]; void init(int n){ for(int i=0;i<n;i++) pos[i]=i; } int findset(int a){ if(pos[a]==a) return a; else findset(pos[a]); } void unionset(int A, int B){ int a=findset(A); int b=findset(B); if(a!=b) pos[b]=a; } int construct(int p[][]) { int n=(int)sqrt(sizeof(p)/4); init(n); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]==1) unionset(i,j); } } vector<int> v[n]; for(int i=0;i<n;i++) v[findset(i)].push_back(i); int res[n][n]; memset(res,0,sizeof(res)); for(int i=0;i<n;i++){ for(int j=0;j<v[i].size()-1;j++){ res[j][j+1]=1; } } build(res[][]); return 1; return 0; }

Compilation message (stderr)

supertrees.cpp:23:19: error: declaration of 'p' as multidimensional array must have bounds for all dimensions except the first
   23 | int construct(int p[][])
      |                   ^
supertrees.cpp: In function 'int construct(...)':
supertrees.cpp:25:28: error: 'p' was not declared in this scope
   25 |     int n=(int)sqrt(sizeof(p)/4);
      |                            ^
supertrees.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j=0;j<v[i].size()-1;j++){
      |                     ~^~~~~~~~~~~~~~
supertrees.cpp:45:15: error: expected primary-expression before ']' token
   45 |     build(res[][]);
      |               ^
supertrees.cpp:45:17: error: expected primary-expression before ']' token
   45 |     build(res[][]);
      |                 ^
supertrees.cpp: In function 'int findset(int)':
supertrees.cpp:14:17: warning: control reaches end of non-void function [-Wreturn-type]
   14 |     else findset(pos[a]);
      |          ~~~~~~~^~~~~~~~