제출 #1063086

#제출 시각아이디문제언어결과실행 시간메모리
1063086Ahmed57Split the Attractions (IOI19_split)C++17
컴파일 에러
0 ms0 KiB
vector<int> adj[100001]; int sz[100001],dep[100001]; void precomp(int i,int pr){ sz[i] =1; dep[i] = dep[pr]+1; for(auto j:adj[i]){ if(j==pr)continue; precomp(j,i); sz[i]+=sz[j]; } } vector<pair<int,int>> typ[2]; void lol(int i,int pr,int uni,int passed,int de){ typ[passed].push_back({de,i}); for(auto j:adj[i]){ if(j==pr)continue; lol(j,i,uni,passed|(j==uni),de+1); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p,vector<int> q){ for(int i = 0;i<p.size();i++){ adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]); } int inda = 1 , indb = 2 , indc = 3; if(a>b){swap(a,b);swap(inda,indb);} if(b>c){swap(b,c);swap(indb,indc);} if(a>b){swap(a,b);swap(inda,indb);} if(b>c){swap(b,c);swap(indb,indc);} precomp(0,0); int nod = -1 , pr = -1; int mi = 1e9; for(int i = 0;i<n;i++){ for(auto j:adj[i]){ if(dep[j]<dep[i]){ if(sz[i]>=a&&mi>=sz[i]){ nod = i; pr = j; mi = sz[i]; } }else{ if(n-sz[j]>=a&&mi>=n-sz[j]){ nod = i; pr = j; mi = n-sz[j]; } } } } if(n-mi>=b){ vector<int> ans(n,0); int A = mi; int B = n-mi; lol(pr,pr,nod,0,1); sort(typ[0].begin(),typ[0].end()); sort(typ[1].begin(),typ[1].end()); reverse(typ[0].begin(),typ[0].end()); reverse(typ[1].begin(),typ[1].end()); int lol = (n-mi)-b; int val = c-lol; for(int i = 0;i<typ[1].size();i++){ if(i<val)ans[typ[1][i].second] = indc; else ans[typ[1][i].second] = inda; } for(int i = 0;i<typ[0].size();i++){ if(i<lol)ans[typ[1][i].second] = indc; else ans[typ[1][i].second] = inda; } return ans; }else{ vector<int> ans(n,0); return ans; } }

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

split.cpp:2:1: error: 'vector' does not name a type
    2 | vector<int> adj[100001];
      | ^~~~~~
split.cpp: In function 'void precomp(int, int)':
split.cpp:7:16: error: 'adj' was not declared in this scope
    7 |     for(auto j:adj[i]){
      |                ^~~
split.cpp: At global scope:
split.cpp:13:1: error: 'vector' does not name a type
   13 | vector<pair<int,int>> typ[2];
      | ^~~~~~
split.cpp: In function 'void lol(int, int, int, int, int)':
split.cpp:15:5: error: 'typ' was not declared in this scope
   15 |     typ[passed].push_back({de,i});
      |     ^~~
split.cpp:16:16: error: 'adj' was not declared in this scope
   16 |     for(auto j:adj[i]){
      |                ^~~
split.cpp: At global scope:
split.cpp:21:1: error: 'vector' does not name a type
   21 | vector<int> find_split(int n, int a, int b, int c, vector<int> p,vector<int> q){
      | ^~~~~~