제출 #737177

#제출 시각아이디문제언어결과실행 시간메모리
737177ammar2000Split the Attractions (IOI19_split)C++17
33 / 100
121 ms29876 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; void dfsc(int x=1) { isvis[x]=1; if (aa>tr) ret[x-1]=1; else if (aa+bb>tr) ret[x-1]=2; else ret[x-1]=3; tr++; 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); 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); } aa=a; bb=b; cc=c; nn=n; 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); } } else { dfsc(); } return ret; }

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

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