This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include"split.h"
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
vector<ll> g[100010];
ll col[100010];
ll paint(ll x,ll from,ll rem,ll c){
if(~col[x])return rem;
if(rem<=0)return 0;
col[x]=c;
rem--;
for(auto y:g[x])if(y!=from){
rem=paint(y,x,rem,c);
}
return rem;
}
vector<int> find_split(int N,int A,int B,int C,vector<int> U,vector<int> V){
int M=U.size();
assert(A==1);
rep(i,M){
g[U[i]].push_back(V[i]);
g[V[i]].push_back(U[i]);
}
rep(i,N)col[i]=-1;
paint(0,-1,B,2);
bool fi=1;
rep(i,N){
if(col[i]!=2){
if(fi)col[i]=1;
else col[i]=3;
fi=0;
}
}
vector<int> fans;
rep(i,N)fans.push_back(col[i]);
return fans;
}
/*
int main(){
int n,m,a,b,c;
cin>>n>>m>>a>>b>>c;
vector<int> U,V;
rep(i,m){
ll u,v;
cin>>u>>v;
U.push_back(u);
V.push_back(v);
}
vector<int> fans=find_split(n,a,b,c,U,V);
for(auto t:fans)cout<<t;
cout<<endl;
}*/
Compilation message (stderr)
split.cpp:18:0: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
#pragma gcc optimize("O3")
split.cpp:19:0: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
#pragma gcc optimize("unroll-loops")
split.cpp:20:0: warning: ignoring #pragma gcc target [-Wunknown-pragmas]
#pragma gcc target("avx2,see4")
# | 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... |