제출 #309393

#제출 시각아이디문제언어결과실행 시간메모리
309393pere_gil슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.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) p[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; }

컴파일 시 표준 에러 (stderr) 메시지

supertrees.cpp: In function 'void unionset(int, int)':
supertrees.cpp:19:14: error: 'p' was not declared in this scope
   19 |     if(a!=b) p[b]=a;
      |              ^
supertrees.cpp: At global scope:
supertrees.cpp:22:22: error: multidimensional array must have bounds for all dimensions except the first
   22 | int construct(int [][] p)
      |                      ^
supertrees.cpp:22:24: error: expected ',' or '...' before 'p'
   22 | int construct(int [][] p)
      |                        ^
supertrees.cpp: In function 'int construct()':
supertrees.cpp:24:28: error: 'p' was not declared in this scope
   24 |     int n=(int)sqrt(sizeof(p)/4);
      |                            ^
supertrees.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int j=0;j<v[i].size()-1;j++){
      |                     ~^~~~~~~~~~~~~~
supertrees.cpp:44:5: error: 'build' was not declared in this scope
   44 |     build(res);
      |     ^~~~~
supertrees.cpp: In function 'int findset(int)':
supertrees.cpp:13:17: warning: control reaches end of non-void function [-Wreturn-type]
   13 |     else findset(pos[a]);
      |          ~~~~~~~^~~~~~~~