제출 #299904

#제출 시각아이디문제언어결과실행 시간메모리
299904dsjongSplit the Attractions (IOI19_split)C++14
0 / 100
120 ms9268 KiB
#include "split.h" #include <bits/stdc++.h> #define pii pair<int, int> using namespace std; vector<int>adj[100005]; int par[100005], sum[100005], ans[100005]; pii A, B; bool done=false; int cnter, bad, n, head=-1; void go(int x, int p, int v){ if(cnter && !ans[x]){ cnter--; ans[x]=v; } for(int y:adj[x]){ if(y==p) continue; go(y, x, v); } } void dfs(int x, int p){ par[x]=p; sum[x]=1; vector<pair<int, int>>cur; for(int y:adj[x]){ if(y==p) continue; dfs(y, x); sum[x]+=sum[y]; cur.push_back({sum[y], y}); } cur.push_back({n-sum[x], p}); if(done) return; for(auto [x, y]: cur){ if(x>=A.first && n-x>=B.first){ head=y; break; } if(x>=B.first && n-x>=A.first){ head=y; swap(A, B); break; } } //A is baby if(head==-1) return; cnter=A.first; go(head, x, A.second); cnter=B.first; go(x, -1, B.second); for(int i=0;i<n;i++){ if(!ans[i]) ans[i]=bad; } done=true; } vector<int> find_split(int _n, int a, int b, int c, vector<int> p, vector<int> q) { n=_n; assert((int) p.size()==n-1); for(int i=0;i<p.size();i++){ int x=p[i], y=q[i]; adj[x].push_back(y); adj[y].push_back(x); } vector<pii>v={{a, 1}, {b, 2}, {c, 3}}; sort(v.begin(), v.end()); A=v[0], B=v[1], bad=v[2].second; dfs(0, -1); vector<int>fans; for(int i=0;i<n;i++){ fans.push_back(ans[i]); } return fans; }

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

split.cpp: In function 'void dfs(int, int)':
split.cpp:32:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |  for(auto [x, y]: cur){
      |           ^
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i=0;i<p.size();i++){
      |              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...