제출 #429127

#제출 시각아이디문제언어결과실행 시간메모리
429127MOUF_MAHMALATSplit the Attractions (IOI19_split)C++14
22 / 100
592 ms1048580 KiB
#include "split.h" #include<bits/stdc++.h> using namespace std; typedef int ll; ll sz[100009],x=-1,y=-1,is,c,n; vector<ll>ans; vector<vector<ll> >v; pair<ll,ll>id[3]; void dfs(ll d,ll pp) { sz[d]=1; for(auto z:v[d]) if(z!=pp) { dfs(z,d); sz[d]+=sz[z]; } if(x>-1) return; for(auto z:v[d]) if(z!=pp) { if(sz[z]>=id[0].first&&n-sz[z]>=id[1].first) { x=z,y=d; return; } if(sz[z]>=id[1].first&&n-sz[z]>=id[0].first) { x=z,y=d,is=1; return; } } } void color(ll d,ll p,ll op) { if(c) c--,ans[d]=op; else ans[d]=id[2].second; for(auto z:v[d]) if(z!=p) color(z,d,op); } vector<int> find_split(int N, int a, int b, int cc, vector<int> p, vector<int> q) { n=N; v.resize(n); ans.resize(n); id[0]= {a,1}; id[1]= {b,2}; id[2]= {cc,3}; sort(id,id+3); for(ll i=0; i<p.size(); i++) { v[p[i]].push_back(q[i]); v[q[i]].push_back(p[i]); } dfs(0,-1); if(x==-1) return ans; if(is) { c=id[1].first; color(x,y,id[1].second); c=id[0].first; color(y,x,id[0].second); } else { c=id[0].first; color(x,y,id[0].second); c=id[1].first; color(y,x,id[1].second); } return ans; }

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

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:54:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(ll 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...