제출 #737181

#제출 시각아이디문제언어결과실행 시간메모리
737181ammar2000Split the Attractions (IOI19_split)C++17
22 / 100
87 ms21324 KiB
#include "split.h" #include<bits/stdc++.h> #define ll long long #define pb push_back #define dp st #define F first #define S second #define coy cout<<"YES\n" #define con cout<<"NO\n" #define co1 cout<<"-1\n" #define sc(x) scanf("%lld",&x) #define all(x) x.begin(),x.end() #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const int SI=3e5+7; ll INF=8e18+7; int MOD=1e9+7; vector<int> ret; bool fou=0; vector <ll> v[SI]; int nn, aa,bb,cc; int p[SI],st[SI]; void bt(int x=1,int pa=0) { p[x]=pa; st[x]=1; for(auto i:v[x]) { if (i==pa) continue; bt(i,x); st[x]+=st[i]; } } int hmtc=0; void dfs(int x,int pa ,int col) { if (hmtc<=0) return ; ret[x-1]=col; hmtc--; for(auto i:v[x]) if(i!=pa) dfs(i,x,col); } void bld(int x,int i,int o,bool k) { if (fou) return ; fou=1; int re; vector <ll> ss(2),ee(2); if (o==0) ss={bb,cc},ee={2,3},re=1; else if (o==1) ss={aa,cc},ee={1,3},re=2; else ss={bb,cc},ee={1,2},re=3; if (k) swap(ss[0],ss[1]),swap(ee[0],ee[1]); hmtc=ss[0]; dfs(i,x,ee[0]); hmtc=ss[1]; dfs(x,i,ee[1]); for(int i=0;i<nn;i++) if(ret[i]==0) ret[i]=re; } void fans(int x=1,int pa=0) { if (x!=1) {st[pa]-=st[x]; st[x]+=st[pa];} // cout <<x<<" " <<pa <<"\n"; for (int o=0;o<3;o++) { vector <ll> ss(2); if (o==0) ss={bb,cc}; else if (o==1) ss={aa,cc}; else ss={bb,cc}; for (auto i:v[x]) { // cout << dp[i]<<" " <<ss[0]<<" " <<dp[x]<<" " <<ss[1]<<"\n"; if (dp[i]>=ss[0]&&dp[x]-dp[i]>=ss[1]) bld(x,i,o,0); else if (dp[i]>=ss[1]&&dp[x]-dp[i]>=ss[1]) bld(x,i,o,1); } } for(auto i:v[x]) if (i!=pa) fans(i,x); if (x!=1) {st[x]-=st[pa]; st[pa]+=st[x]; } } bool rrk=0; int isvis[SI]; int tr=0; vector <ll> colo; void dfsc(int x) { isvis[x]=1; colo.pb(x); for(auto i:v[x]) if (isvis[i]==0) dfsc(i); } void dfsa(int x=1) { isvis[x]=1; if (bb==0) return ; ret[x-1]=2; bb--; for(auto i:v[x]) if (isvis[i]==0) dfsa(i); } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { ret.resize(n); bool k=0; for(int i=0;i<p.size();i++) { int d=p[i],m=q[i]; d++; m++; v[d].pb(m); v[m].pb(d); if (v[d].size()>2||v[m].size()>2) k=1; } aa=a; bb=b; cc=c; nn=n; if (k==0) { int y=1; while(y<=n&&v[y].size()==2) y++; if (y==n) y=1; dfsc(y); for(int i=0;i<n;i++) { int uu=colo[i]-1; if (i<a) ret[uu]=1; else if (i<a+b) ret[uu]=2; else ret[uu]=3; } } else if (n==p.size()+1) {bt(); fans();} else if (a==1) { dfsa(); int u=1; for(int i=0;i<n;i++) { if (ret[i]==0) ret[i]=u,u=min(u+2,3); } } return ret; }

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

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:128:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  128 |  for(int i=0;i<p.size();i++)
      |              ~^~~~~~~~~
split.cpp:160:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  160 |     else if (n==p.size()+1)
      |              ~^~~~~~~~~~~~
#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...