#include "split.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
const int MX = 200005;
vi g[MX],adj[MX];
int par[MX],dep[MX],sz[MX],root;
pii A[MX];
bitset<MX> vis;
vi ans;
void dfs(int u,int p,int d = 0){
par[u] = p;
vis[u] = 1;
dep[u] = d;
sz[u] = 1;
for(auto v:g[u]){
if(vis[v]) continue;
adj[u].pb(v);
adj[v].pb(u);
dfs(v,u,d-1);
sz[u] += sz[v];
}
}
void assign(int u,int val){
vis[u] = 1;
if(A[val].F){
ans[u] = A[val].S;
A[val].F--;
}
else ans[u] = A[2].S;
for(auto v:adj[u]){
if(!vis[v]) assign(v,val);
}
}
vi find_split(int n, int a, int b, int c, vi p, vi q) {
A[0] = {a,1};
A[1] = {b,2};
A[2] = {c,3};
sort(A,A+3);
ans.resize(n);
REP(i,(int)p.size()){
g[p[i]].pb(q[i]);
g[q[i]].pb(p[i]);
}
REP(i,n) adj[i].clear();
vis.reset();
root = 0;
dfs(root,root);
vis.reset();
REP(i,n){
if(sz[i] >= A[0].F and n-sz[i] >= A[0].F){
vis[i] = 1;
if(sz[i] < n-sz[i]){
assign(par[i],1);
assign(i,0);
}
else{
assign(par[i],0);
assign(i,1);
}
return ans;
}
}
int cnt = 0;
REP(i,n){
int mx = n-sz[i];
for(auto v:adj[i]){
if(v != par[i]){
mx = max(mx,sz[v]);
}
}
if(mx < a) cnt++;
}
assert(cnt == 1);
return vi(n,0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9728 KB |
ok, correct split |
2 |
Correct |
7 ms |
9728 KB |
ok, correct split |
3 |
Correct |
7 ms |
9728 KB |
ok, correct split |
4 |
Correct |
7 ms |
9728 KB |
ok, correct split |
5 |
Correct |
7 ms |
9728 KB |
ok, correct split |
6 |
Correct |
7 ms |
9728 KB |
ok, correct split |
7 |
Correct |
133 ms |
27128 KB |
ok, correct split |
8 |
Correct |
134 ms |
24828 KB |
ok, correct split |
9 |
Correct |
134 ms |
24056 KB |
ok, correct split |
10 |
Correct |
141 ms |
27492 KB |
ok, correct split |
11 |
Correct |
138 ms |
27512 KB |
ok, correct split |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9728 KB |
ok, correct split |
2 |
Correct |
7 ms |
9728 KB |
ok, correct split |
3 |
Correct |
7 ms |
9728 KB |
ok, correct split |
4 |
Correct |
169 ms |
24440 KB |
ok, correct split |
5 |
Correct |
122 ms |
19832 KB |
ok, correct split |
6 |
Correct |
141 ms |
27512 KB |
ok, correct split |
7 |
Correct |
145 ms |
24568 KB |
ok, correct split |
8 |
Correct |
175 ms |
21624 KB |
ok, correct split |
9 |
Correct |
127 ms |
19832 KB |
ok, correct split |
10 |
Correct |
85 ms |
20464 KB |
ok, correct split |
11 |
Correct |
88 ms |
20464 KB |
ok, correct split |
12 |
Correct |
94 ms |
20464 KB |
ok, correct split |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
9728 KB |
ok, correct split |
2 |
Correct |
137 ms |
19888 KB |
ok, correct split |
3 |
Correct |
46 ms |
13944 KB |
ok, correct split |
4 |
Correct |
7 ms |
9728 KB |
ok, correct split |
5 |
Correct |
133 ms |
22264 KB |
ok, correct split |
6 |
Correct |
144 ms |
22008 KB |
ok, correct split |
7 |
Correct |
132 ms |
21880 KB |
ok, correct split |
8 |
Correct |
144 ms |
23248 KB |
ok, correct split |
9 |
Correct |
131 ms |
21624 KB |
ok, correct split |
10 |
Correct |
35 ms |
13184 KB |
ok, no valid answer |
11 |
Correct |
53 ms |
14840 KB |
ok, no valid answer |
12 |
Correct |
104 ms |
20340 KB |
ok, no valid answer |
13 |
Correct |
126 ms |
19960 KB |
ok, no valid answer |
14 |
Correct |
89 ms |
20468 KB |
ok, no valid answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9728 KB |
ok, correct split |
2 |
Correct |
7 ms |
9728 KB |
ok, no valid answer |
3 |
Correct |
7 ms |
9728 KB |
ok, correct split |
4 |
Correct |
7 ms |
9728 KB |
ok, correct split |
5 |
Correct |
8 ms |
9728 KB |
ok, correct split |
6 |
Correct |
7 ms |
9728 KB |
ok, correct split |
7 |
Correct |
7 ms |
9728 KB |
ok, correct split |
8 |
Correct |
7 ms |
9728 KB |
ok, correct split |
9 |
Correct |
10 ms |
10112 KB |
ok, correct split |
10 |
Correct |
10 ms |
10112 KB |
ok, correct split |
11 |
Correct |
8 ms |
9728 KB |
ok, correct split |
12 |
Correct |
9 ms |
10112 KB |
ok, correct split |
13 |
Correct |
7 ms |
9728 KB |
ok, correct split |
14 |
Correct |
7 ms |
9728 KB |
ok, correct split |
15 |
Correct |
7 ms |
9728 KB |
ok, correct split |
16 |
Correct |
7 ms |
9728 KB |
ok, correct split |
17 |
Correct |
7 ms |
9728 KB |
ok, correct split |
18 |
Correct |
7 ms |
9728 KB |
ok, correct split |
19 |
Correct |
7 ms |
9856 KB |
ok, correct split |
20 |
Correct |
8 ms |
9956 KB |
ok, correct split |
21 |
Correct |
9 ms |
10112 KB |
ok, correct split |
22 |
Correct |
9 ms |
10112 KB |
ok, correct split |
23 |
Correct |
9 ms |
10112 KB |
ok, correct split |
24 |
Correct |
9 ms |
10112 KB |
ok, correct split |
25 |
Correct |
9 ms |
10112 KB |
ok, correct split |
26 |
Incorrect |
9 ms |
10112 KB |
jury found a solution, contestant did not |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9728 KB |
ok, correct split |
2 |
Correct |
7 ms |
9728 KB |
ok, correct split |
3 |
Correct |
7 ms |
9728 KB |
ok, correct split |
4 |
Correct |
7 ms |
9728 KB |
ok, correct split |
5 |
Correct |
7 ms |
9728 KB |
ok, correct split |
6 |
Correct |
7 ms |
9728 KB |
ok, correct split |
7 |
Correct |
133 ms |
27128 KB |
ok, correct split |
8 |
Correct |
134 ms |
24828 KB |
ok, correct split |
9 |
Correct |
134 ms |
24056 KB |
ok, correct split |
10 |
Correct |
141 ms |
27492 KB |
ok, correct split |
11 |
Correct |
138 ms |
27512 KB |
ok, correct split |
12 |
Correct |
7 ms |
9728 KB |
ok, correct split |
13 |
Correct |
7 ms |
9728 KB |
ok, correct split |
14 |
Correct |
7 ms |
9728 KB |
ok, correct split |
15 |
Correct |
169 ms |
24440 KB |
ok, correct split |
16 |
Correct |
122 ms |
19832 KB |
ok, correct split |
17 |
Correct |
141 ms |
27512 KB |
ok, correct split |
18 |
Correct |
145 ms |
24568 KB |
ok, correct split |
19 |
Correct |
175 ms |
21624 KB |
ok, correct split |
20 |
Correct |
127 ms |
19832 KB |
ok, correct split |
21 |
Correct |
85 ms |
20464 KB |
ok, correct split |
22 |
Correct |
88 ms |
20464 KB |
ok, correct split |
23 |
Correct |
94 ms |
20464 KB |
ok, correct split |
24 |
Correct |
8 ms |
9728 KB |
ok, correct split |
25 |
Correct |
137 ms |
19888 KB |
ok, correct split |
26 |
Correct |
46 ms |
13944 KB |
ok, correct split |
27 |
Correct |
7 ms |
9728 KB |
ok, correct split |
28 |
Correct |
133 ms |
22264 KB |
ok, correct split |
29 |
Correct |
144 ms |
22008 KB |
ok, correct split |
30 |
Correct |
132 ms |
21880 KB |
ok, correct split |
31 |
Correct |
144 ms |
23248 KB |
ok, correct split |
32 |
Correct |
131 ms |
21624 KB |
ok, correct split |
33 |
Correct |
35 ms |
13184 KB |
ok, no valid answer |
34 |
Correct |
53 ms |
14840 KB |
ok, no valid answer |
35 |
Correct |
104 ms |
20340 KB |
ok, no valid answer |
36 |
Correct |
126 ms |
19960 KB |
ok, no valid answer |
37 |
Correct |
89 ms |
20468 KB |
ok, no valid answer |
38 |
Correct |
7 ms |
9728 KB |
ok, correct split |
39 |
Correct |
7 ms |
9728 KB |
ok, no valid answer |
40 |
Correct |
7 ms |
9728 KB |
ok, correct split |
41 |
Correct |
7 ms |
9728 KB |
ok, correct split |
42 |
Correct |
8 ms |
9728 KB |
ok, correct split |
43 |
Correct |
7 ms |
9728 KB |
ok, correct split |
44 |
Correct |
7 ms |
9728 KB |
ok, correct split |
45 |
Correct |
7 ms |
9728 KB |
ok, correct split |
46 |
Correct |
10 ms |
10112 KB |
ok, correct split |
47 |
Correct |
10 ms |
10112 KB |
ok, correct split |
48 |
Correct |
8 ms |
9728 KB |
ok, correct split |
49 |
Correct |
9 ms |
10112 KB |
ok, correct split |
50 |
Correct |
7 ms |
9728 KB |
ok, correct split |
51 |
Correct |
7 ms |
9728 KB |
ok, correct split |
52 |
Correct |
7 ms |
9728 KB |
ok, correct split |
53 |
Correct |
7 ms |
9728 KB |
ok, correct split |
54 |
Correct |
7 ms |
9728 KB |
ok, correct split |
55 |
Correct |
7 ms |
9728 KB |
ok, correct split |
56 |
Correct |
7 ms |
9856 KB |
ok, correct split |
57 |
Correct |
8 ms |
9956 KB |
ok, correct split |
58 |
Correct |
9 ms |
10112 KB |
ok, correct split |
59 |
Correct |
9 ms |
10112 KB |
ok, correct split |
60 |
Correct |
9 ms |
10112 KB |
ok, correct split |
61 |
Correct |
9 ms |
10112 KB |
ok, correct split |
62 |
Correct |
9 ms |
10112 KB |
ok, correct split |
63 |
Incorrect |
9 ms |
10112 KB |
jury found a solution, contestant did not |
64 |
Halted |
0 ms |
0 KB |
- |