제출 #1221102

#제출 시각아이디문제언어결과실행 시간메모리
1221102hmms127Connecting Supertrees (IOI20_supertrees)C++20
컴파일 에러
0 ms0 KiB
#include "supertrees.h" #include <vector> using namespace std; struct DSU{ vector<int>par,sz; void init(int n){ par.resize(n+1);sz.resize(n+1); f2(0,n,1)par[i]=i,sz[i]=1; } int root(int u){ return par[u]==u ? u:par[u]=root(par[u]); } bool merge(int u,int v){ int ru=root(u),rv=root(v); if(ru==rv)return 0; if(sz[ru]>sz[rv])swap(sz[ru],sz[rv]); par[ru]=rv;sz[rv]+=sz[ru]; return 1; } }; int construct(std::vector<std::vector<int>> p) { int n=p[0].size(); vector<vector<int>>v(n,vector<int>(n,0)); for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(i==j)continue; if(p[i][j]){ if(d.root(i)==d.root(j))return 0; d.merge(u,v); v[i][j]=1; v[j][i]=1; } } } for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(p[i][j])continue; if(d.root(i)==d.root(j))return 0; } } build(v); return 1; }

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

supertrees.cpp: In member function 'void DSU::init(int)':
supertrees.cpp:8:7: error: 'f2' was not declared in this scope
    8 |       f2(0,n,1)par[i]=i,sz[i]=1;
      |       ^~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:29:16: error: 'd' was not declared in this scope
   29 |             if(d.root(i)==d.root(j))return 0;
      |                ^
supertrees.cpp:30:13: error: 'd' was not declared in this scope
   30 |             d.merge(u,v);
      |             ^
supertrees.cpp:30:21: error: 'u' was not declared in this scope
   30 |             d.merge(u,v);
      |                     ^
supertrees.cpp:39:16: error: 'd' was not declared in this scope
   39 |             if(d.root(i)==d.root(j))return 0;
      |                ^