제출 #309410

#제출 시각아이디문제언어결과실행 시간메모리
309410pere_gil슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "supertrees.h" using namespace std; int pos[1001]; 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; } bool issameset(int a, int b){ if(setfind(a)==setfind(b)) return true; else return false; } int construct(std::vector<std::vector<int>> p) { int n = p.size(); 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> ja[n]; for(int i=0;i<n;i++) ja[findset(i)].push_back(i); bool semamo=false; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(issameset(i,j) and p[i][j]==0) semamo=true; } } if(semamo) return 0; int res[n][n]; memset(res,0,sizeof(res)); for(int i=0;i<n;i++){ for(int j=0;j<ja[i].size()-1;j++) res[ja[i][j]][ja[i][j+1]]=1; } for (int i = 0; i < n; i++) { std::vector<int> row; for(int j=0;j<n;j++) row.push_back(res[i][j]); row.resize(n); answer.push_back(row); } build(answer); return 1; return 0; }

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

supertrees.cpp: In function 'bool issameset(int, int)':
supertrees.cpp:24:8: error: 'setfind' was not declared in this scope; did you mean 'setns'?
   24 |     if(setfind(a)==setfind(b)) return true;
      |        ^~~~~~~
      |        setns
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int j=0;j<ja[i].size()-1;j++) res[ja[i][j]][ja[i][j+1]]=1;
      |                     ~^~~~~~~~~~~~~~~
supertrees.cpp:61:9: error: 'answer' was not declared in this scope
   61 |         answer.push_back(row);
      |         ^~~~~~
supertrees.cpp:64:11: error: 'answer' was not declared in this scope
   64 |     build(answer);
      |           ^~~~~~
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]);
      |          ~~~~~~~^~~~~~~~
supertrees.cpp: In function 'bool issameset(int, int)':
supertrees.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^