이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
typedef long long ll;
ll pie(ll army){return (1ll<<army);}
#include "split.h"
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define mid ((left+right)>>1)
const ll inf=2000000000000000005;
const int sonsuz=2000000005;
using namespace std;
ll fpow(ll x,ll y,ll m=0){if(y<0){cout<<"powError";return -1;}if(m)x%=m;ll res=1;while(y>0){if(y&1)res*=x;x*=x;if(m){x%=m;res%=m;}y>>=1;}return res;}
int N;
int aa=-1,bb=-1;
int tur[3],per[3];
vector<int>komsu[100000];
vector<int>child[100000];
int sub[100000],par[100000];
int res[100000];
int vis[100000];
int f(int pos){
sub[pos]=1;
vis[pos]=1;
int cur=-2;
for(int x:komsu[pos]){
if(par[pos]==x)continue;
if(vis[x])continue;
child[pos].pb(x);
par[x]=pos;
int y=f(x);
if(y==-1)return -1;
if(y!=-2)if(cur==-2||sub[y]<sub[cur])
cur=y;
sub[pos]+=sub[x];
}
if(cur!=-2){
if(sub[pos]-sub[cur]>=tur[per[1]]){
aa=cur;bb=pos;
return -1;
}
}
else{
if(sub[pos]>=tur[per[0]])
cur=pos;
}
return cur;
}
int boya(int pos,int renk,int kalan){
if(res[pos])return kalan;
res[pos]=renk;
kalan--;
if(kalan){
for(int x:child[pos]){
kalan=boya(x,renk,kalan);
if(!kalan)break;
}
}
return kalan;
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
ios_base::sync_with_stdio(false);cin.tie(NULL);
N=n;
tur[0]=a;tur[1]=b;tur[2]=c;
iota(per,per+3,0);
sort(per,per+3,[&](const int &x,const int &y){return tur[x]<tur[y];});
for(int i=0;i<p.size();i++){
komsu[p[i]].pb(q[i]);
komsu[q[i]].pb(p[i]);
}
par[0]=-1;
if(f(0)!=-1){
vector<int>ans;
for(int i=0;i<N;i++){
ans.pb(0);
}
return ans;
}
boya(aa,per[0]+1,tur[per[0]]);
boya(bb,per[1]+1,tur[per[1]]);
int ek=per[2]+1;
vector<int>ans;
for(int i=0;i<n;i++){
if(res[i]){
ans.pb(res[i]);
}
else ans.pb(ek);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:71:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for(int i=0;i<p.size();i++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |