#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef double db;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define po pop_back
#define pb push_back
#define mk make_pair
#define mt make_tuple
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define BOOST ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18
#define MIN -1e18
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
#define read(x) scanf("%lld",&x);
#define print(x) printf("%lld ",x);
#define endl '\n';
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,ans,mid,mn,mx,T,sum,h1,h2,e[1234567],b[1234567],c[1234567],d[1<<20],k,i,j,l,r,h,a[1234567],w,x,y,z,res,par[1234567],cnt,sz[1234567];
bool used[1234567];
vl v[1234567],vec1;
char s1[1234567],s[1234567],ss[1234567];
vector<pl> vp[1234567];
bool ok;
map<ll,ll> mp;
ll c1[2234][2234],c2[1234][1234];
char ch[2234][2234];
ll dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
vl vec;
vector<int> vv1,vv2;
void dfs(int x,int p){
if(sz[x]>0)return;
sz[x]=1;
par[x]=p;
for(auto u:v[x]){
if(p!=u)dfs(u,x),sz[x]+=sz[u];
}
}
void dfs1(int x){
used[x]=1;
for(auto u:v[x]){
if(used[u]==0&&par[u]==x)dfs1(u);
}
vv1.pb(x);
}
void dfs2(int x){
if(used[x]==1)return;
for(auto u:v[x]){
if(par[u]==x)dfs2(u);
}
vv2.pb(x);
}
vector<int> find_split(int n,int a,int b,int c, vector<int>v1,vector<int>v2){
rep(i,0,v1.size()-1){
v[v1[i]].pb(v2[i]);
v[v2[i]].pb(v1[i]);
}
vector<int> ans(n);
dfs(0,-1);
vector<pair<int,int>> vv{{a,1},{b,2},{c,3}};
sort(vv.begin(),vv.end());
rep(i,0,n-1){
if(sz[i]>=vv[0].ff&&n-sz[i]>=vv[1].ff){
dfs1(i);
dfs2(0);
rep(j,0,vv1.size()-1){
if(j<vv[0].ff)ans[vv1[j]]=vv[0].ss;
else ans[vv1[j]]=vv[2].ss;
}
rep(j,0,vv2.size()-1){
if(j<vv[1].ff)ans[vv2[j]]=vv[1].ss;
else ans[vv2[j]]=vv[2].ss;
}
}
else{
if(sz[i]>=vv[1].ff&&n-sz[i]>=vv[0].ff){
dfs1(i);
dfs2(0);
rep(j,0,vv1.size()-1){
if(j<vv[1].ff)ans[vv1[j]]=vv[1].ss;
else ans[vv1[j]]=vv[2].ss;
}
rep(j,0,vv2.size()-1){
if(j<vv[0].ff)ans[vv2[j]]=vv[0].ss;
else ans[vv2[j]]=vv[2].ss;
}
}
}
}
return ans;
}
Compilation message
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:20:32: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | #define rep(i,a,b) for(ll i=a;i<=b;i++)
......
66 | rep(i,0,v1.size()-1){
| ~~~~~~~~~~~~~~~
split.cpp:66:5: note: in expansion of macro 'rep'
66 | rep(i,0,v1.size()-1){
| ^~~
split.cpp:20:32: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | #define rep(i,a,b) for(ll i=a;i<=b;i++)
......
78 | rep(j,0,vv1.size()-1){
| ~~~~~~~~~~~~~~~~
split.cpp:78:13: note: in expansion of macro 'rep'
78 | rep(j,0,vv1.size()-1){
| ^~~
split.cpp:20:32: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | #define rep(i,a,b) for(ll i=a;i<=b;i++)
......
82 | rep(j,0,vv2.size()-1){
| ~~~~~~~~~~~~~~~~
split.cpp:82:13: note: in expansion of macro 'rep'
82 | rep(j,0,vv2.size()-1){
| ^~~
split.cpp:20:32: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | #define rep(i,a,b) for(ll i=a;i<=b;i++)
......
91 | rep(j,0,vv1.size()-1){
| ~~~~~~~~~~~~~~~~
split.cpp:91:17: note: in expansion of macro 'rep'
91 | rep(j,0,vv1.size()-1){
| ^~~
split.cpp:20:32: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | #define rep(i,a,b) for(ll i=a;i<=b;i++)
......
95 | rep(j,0,vv2.size()-1){
| ~~~~~~~~~~~~~~~~
split.cpp:95:17: note: in expansion of macro 'rep'
95 | rep(j,0,vv2.size()-1){
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
58368 KB |
ok, correct split |
2 |
Correct |
41 ms |
58360 KB |
ok, correct split |
3 |
Incorrect |
40 ms |
58360 KB |
invalid split: #1=0, #2=1, #3=3 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
58360 KB |
invalid split: #1=0, #2=0, #3=3 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
58368 KB |
invalid split: #1=1, #2=1, #3=3 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
58292 KB |
invalid split: #1=9, #2=0, #3=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
58368 KB |
ok, correct split |
2 |
Correct |
41 ms |
58360 KB |
ok, correct split |
3 |
Incorrect |
40 ms |
58360 KB |
invalid split: #1=0, #2=1, #3=3 |
4 |
Halted |
0 ms |
0 KB |
- |