Submission #296503

# Submission time Handle Problem Language Result Execution time Memory
296503 2020-09-10T15:27:09 Z b00n0rp Split the Attractions (IOI19_split) C++17
18 / 100
2000 ms 27384 KB
#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];
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(root,n){
		REP(i,n) adj[i].clear();
		vis.reset();
		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;
			}
		}
	}
	return vi(n,0);
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9728 KB ok, correct split
2 Correct 6 ms 9728 KB ok, correct split
3 Correct 6 ms 9728 KB ok, correct split
4 Correct 7 ms 9760 KB ok, correct split
5 Correct 7 ms 9728 KB ok, correct split
6 Correct 6 ms 9728 KB ok, correct split
7 Correct 132 ms 27000 KB ok, correct split
8 Correct 140 ms 24772 KB ok, correct split
9 Correct 128 ms 24056 KB ok, correct split
10 Correct 130 ms 27384 KB ok, correct split
11 Correct 133 ms 27384 KB ok, correct split
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9728 KB ok, correct split
2 Correct 6 ms 9728 KB ok, correct split
3 Correct 7 ms 9856 KB ok, correct split
4 Correct 162 ms 24304 KB ok, correct split
5 Correct 112 ms 19704 KB ok, correct split
6 Correct 126 ms 27384 KB ok, correct split
7 Correct 149 ms 24568 KB ok, correct split
8 Correct 168 ms 21624 KB ok, correct split
9 Correct 117 ms 19576 KB ok, correct split
10 Correct 82 ms 20336 KB ok, correct split
11 Correct 83 ms 20336 KB ok, correct split
12 Correct 84 ms 20336 KB ok, correct split
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9728 KB ok, correct split
2 Correct 114 ms 19704 KB ok, correct split
3 Correct 42 ms 13816 KB ok, correct split
4 Correct 6 ms 9728 KB ok, correct split
5 Correct 125 ms 22136 KB ok, correct split
6 Correct 128 ms 21880 KB ok, correct split
7 Correct 130 ms 21752 KB ok, correct split
8 Correct 125 ms 23032 KB ok, correct split
9 Correct 128 ms 21496 KB ok, correct split
10 Execution timed out 2082 ms 12920 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9728 KB ok, correct split
2 Correct 6 ms 9728 KB ok, no valid answer
3 Correct 7 ms 9728 KB ok, correct split
4 Correct 6 ms 9728 KB ok, correct split
5 Correct 7 ms 9728 KB ok, correct split
6 Correct 6 ms 9728 KB ok, correct split
7 Correct 7 ms 9728 KB ok, correct split
8 Correct 6 ms 9728 KB ok, correct split
9 Correct 9 ms 10112 KB ok, correct split
10 Correct 9 ms 9984 KB ok, correct split
11 Correct 7 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 6 ms 9728 KB ok, correct split
15 Correct 6 ms 9728 KB ok, correct split
16 Correct 6 ms 9728 KB ok, correct split
17 Correct 6 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 9888 KB ok, correct split
21 Correct 8 ms 10112 KB ok, correct split
22 Correct 10 ms 9984 KB ok, correct split
23 Correct 8 ms 10112 KB ok, correct split
24 Correct 8 ms 10112 KB ok, correct split
25 Correct 8 ms 10112 KB ok, correct split
26 Incorrect 180 ms 10196 KB jury found a solution, contestant did not
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9728 KB ok, correct split
2 Correct 6 ms 9728 KB ok, correct split
3 Correct 6 ms 9728 KB ok, correct split
4 Correct 7 ms 9760 KB ok, correct split
5 Correct 7 ms 9728 KB ok, correct split
6 Correct 6 ms 9728 KB ok, correct split
7 Correct 132 ms 27000 KB ok, correct split
8 Correct 140 ms 24772 KB ok, correct split
9 Correct 128 ms 24056 KB ok, correct split
10 Correct 130 ms 27384 KB ok, correct split
11 Correct 133 ms 27384 KB ok, correct split
12 Correct 6 ms 9728 KB ok, correct split
13 Correct 6 ms 9728 KB ok, correct split
14 Correct 7 ms 9856 KB ok, correct split
15 Correct 162 ms 24304 KB ok, correct split
16 Correct 112 ms 19704 KB ok, correct split
17 Correct 126 ms 27384 KB ok, correct split
18 Correct 149 ms 24568 KB ok, correct split
19 Correct 168 ms 21624 KB ok, correct split
20 Correct 117 ms 19576 KB ok, correct split
21 Correct 82 ms 20336 KB ok, correct split
22 Correct 83 ms 20336 KB ok, correct split
23 Correct 84 ms 20336 KB ok, correct split
24 Correct 6 ms 9728 KB ok, correct split
25 Correct 114 ms 19704 KB ok, correct split
26 Correct 42 ms 13816 KB ok, correct split
27 Correct 6 ms 9728 KB ok, correct split
28 Correct 125 ms 22136 KB ok, correct split
29 Correct 128 ms 21880 KB ok, correct split
30 Correct 130 ms 21752 KB ok, correct split
31 Correct 125 ms 23032 KB ok, correct split
32 Correct 128 ms 21496 KB ok, correct split
33 Execution timed out 2082 ms 12920 KB Time limit exceeded
34 Halted 0 ms 0 KB -