Submission #298175

# Submission time Handle Problem Language Result Execution time Memory
298175 2020-09-12T13:43:05 Z pit4h Amusement Park (JOI17_amusement_park) C++14
80 / 100
43 ms 7292 KB
#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int _N = 1e4+1, _B = 60;
vector<int> g[_N];
bool vis[_N];
int dep[_N], par[_N], subt[_N];
vector<int> roots;
ll X;
void dfs(int x) {
	vis[x] = 1;
	subt[x] = 1;
	for(int i: g[x]) {
		if(!vis[i]) {
			par[i] = x;
			dep[i] = dep[x]+1;
			dfs(i);
			subt[x] += subt[i];
		}
	}
	if(dep[x]%_B==0 && subt[x] >= _B) {
		roots.push_back(x);
	}
}
void set_board(int x, int &bit) {
	vis[x] = 1;	
	if((X&(1LL<<bit))>0) {
		MessageBoard(x, 1);
	}
	else {
		MessageBoard(x, 0);
	}
	if(bit>=_B-1) return;
	for(int i: g[x]) {
		if(!vis[i] && par[i] == x) {
			bit++;
			if(dep[i]%_B!=0 && bit<_B) set_board(i, bit);
		}
	}
}
void Joi(int N, int M, int A[], int B[], ll _X, int T) {
	// MessageBoard();
	X = _X;
	for(int i=0; i<M; ++i) {
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}
	for(int i=0; i<N; ++i) {
		sort(g[i].begin(), g[i].end());
	}
	dfs(0);
	for(int i=0; i<N; ++i) vis[i] = 0;
	for(int i: roots) {
		int bit = 0;
		set_board(i, bit);
	}
	for(int i=0; i<N; ++i) {
		if(!vis[i]) {
			MessageBoard(i, 1);
		}
	}
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int __N = 1e4+1;
const int bits = 60;
int _subt[__N];
void _dfs(int x, vector<int>& vis, vector<vector<int>>& g, vector<int>& par, vector<int>& dep) {
	vis[x] = 1;
	_subt[x] = 1;
	for(int i: g[x]) {
		if(!vis[i]) {
			par[i] = x;
			dep[i] = dep[x]+1;
			_dfs(i, vis, g, par, dep);
			_subt[x] += _subt[i];
		}
	}
}
int cnt;
map<int, int> Map[__N];
int cur_pos;
int mv(int x) {
	//cnt++;
	if(!Map[cur_pos][x] || cnt > 200) assert(false);
	cur_pos = x;
	return Move(x);
}
void get_X(int x, int v, int& bit, ll& X, vector<int>& vis, vector<vector<int>>& g, vector<int>& par) { 
	vis[x] = 1;
	X += (ll)v * (1LL<<bit);
	if(bit==bits-1) return;
	for(int i: g[x]) {
		if(!vis[i] && par[i]==x) {
			bit++;
			if(bit < bits) get_X(i, mv(i), bit, X, vis, g, par);
		}
	}
	if(par[x] != x && bit < bits-1) {
		mv(par[x]);
	}
}	
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
	vector<vector<int>> g(N);
	vector<int> vis(N), par(N), dep(N);
	for(int i=0; i<M; ++i) {
		Map[A[i]][B[i]] = 1;
		Map[B[i]][A[i]] = 1;
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}
	for(int i=0; i<N; ++i) {
		sort(g[i].begin(), g[i].end());
	}
	_dfs(0, vis, g, par, dep);
	cur_pos = P;
	while(dep[P]%bits != 0 || _subt[P] < bits) {
		P = par[P];
		V = mv(P);
	}
	for(int i=0; i<N; ++i) {
		vis[i] = 0;
	}
	int bit = 0;
	ll X = 0;
	get_X(P, V, bit, X, vis, g, par);
	return X;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1788 KB Output is correct
2 Correct 2 ms 1796 KB Output is correct
3 Correct 2 ms 1776 KB Output is correct
4 Correct 2 ms 1672 KB Output is correct
5 Correct 2 ms 1796 KB Output is correct
6 Correct 2 ms 1544 KB Output is correct
7 Correct 2 ms 1680 KB Output is correct
8 Correct 2 ms 1780 KB Output is correct
9 Correct 3 ms 1780 KB Output is correct
10 Correct 2 ms 1600 KB Output is correct
11 Correct 9 ms 2320 KB Output is correct
12 Correct 3 ms 1656 KB Output is correct
13 Correct 2 ms 1552 KB Output is correct
14 Correct 2 ms 1680 KB Output is correct
15 Correct 2 ms 1552 KB Output is correct
16 Correct 2 ms 1904 KB Output is correct
17 Correct 2 ms 1680 KB Output is correct
18 Correct 2 ms 1780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 6920 KB Output is correct
2 Correct 41 ms 7292 KB Output is correct
3 Correct 43 ms 7268 KB Output is correct
4 Correct 23 ms 4756 KB Output is correct
5 Correct 22 ms 5196 KB Output is correct
6 Correct 24 ms 5264 KB Output is correct
7 Correct 25 ms 5036 KB Output is correct
8 Correct 25 ms 5164 KB Output is correct
9 Correct 23 ms 5036 KB Output is correct
10 Correct 23 ms 4724 KB Output is correct
11 Correct 26 ms 4856 KB Output is correct
12 Correct 19 ms 4304 KB Output is correct
13 Correct 20 ms 4492 KB Output is correct
14 Correct 20 ms 4384 KB Output is correct
15 Correct 22 ms 4892 KB Output is correct
16 Correct 22 ms 4524 KB Output is correct
17 Correct 23 ms 4752 KB Output is correct
18 Correct 23 ms 4524 KB Output is correct
19 Correct 23 ms 4752 KB Output is correct
20 Correct 20 ms 5184 KB Output is correct
21 Correct 18 ms 5420 KB Output is correct
22 Correct 23 ms 5036 KB Output is correct
23 Correct 23 ms 5164 KB Output is correct
24 Correct 22 ms 5148 KB Output is correct
25 Correct 25 ms 5036 KB Output is correct
26 Correct 22 ms 5224 KB Output is correct
27 Correct 24 ms 5164 KB Output is correct
28 Correct 23 ms 5208 KB Output is correct
29 Correct 23 ms 4780 KB Output is correct
30 Correct 24 ms 5148 KB Output is correct
31 Correct 2 ms 1672 KB Output is correct
32 Correct 2 ms 1784 KB Output is correct
33 Correct 2 ms 1776 KB Output is correct
34 Correct 2 ms 1544 KB Output is correct
35 Correct 2 ms 1544 KB Output is correct
36 Correct 2 ms 1672 KB Output is correct
37 Correct 2 ms 1544 KB Output is correct
38 Correct 2 ms 1792 KB Output is correct
39 Correct 2 ms 1656 KB Output is correct
40 Correct 2 ms 1912 KB Output is correct
41 Correct 2 ms 1788 KB Output is correct
42 Correct 2 ms 1916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1708 KB Output is correct
2 Correct 2 ms 1784 KB Output is correct
3 Correct 2 ms 1668 KB Output is correct
4 Correct 6 ms 2268 KB Output is correct
5 Correct 4 ms 2264 KB Output is correct
6 Correct 4 ms 2084 KB Output is correct
7 Correct 5 ms 2260 KB Output is correct
8 Correct 4 ms 2256 KB Output is correct
9 Correct 18 ms 5720 KB Output is correct
10 Correct 18 ms 5724 KB Output is correct
11 Correct 19 ms 5836 KB Output is correct
12 Correct 2 ms 1784 KB Output is correct
13 Correct 2 ms 1780 KB Output is correct
14 Correct 2 ms 1540 KB Output is correct
15 Correct 2 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 42 ms 6912 KB Partially correct
2 Correct 41 ms 7172 KB Output is correct
3 Correct 40 ms 7160 KB Output is correct
4 Correct 22 ms 4652 KB Output is correct
5 Correct 23 ms 5420 KB Output is correct
6 Partially correct 23 ms 5216 KB Partially correct
7 Correct 24 ms 5228 KB Output is correct
8 Correct 23 ms 4924 KB Output is correct
9 Correct 23 ms 5036 KB Output is correct
10 Correct 24 ms 4656 KB Output is correct
11 Correct 24 ms 4720 KB Output is correct
12 Correct 20 ms 4492 KB Output is correct
13 Partially correct 19 ms 4244 KB Partially correct
14 Partially correct 20 ms 4524 KB Partially correct
15 Correct 23 ms 4476 KB Output is correct
16 Correct 23 ms 4652 KB Output is correct
17 Correct 23 ms 4764 KB Output is correct
18 Partially correct 23 ms 4760 KB Partially correct
19 Partially correct 22 ms 4524 KB Partially correct
20 Partially correct 18 ms 5164 KB Partially correct
21 Correct 18 ms 5188 KB Output is correct
22 Correct 25 ms 5232 KB Output is correct
23 Correct 23 ms 4908 KB Output is correct
24 Partially correct 23 ms 5136 KB Partially correct
25 Partially correct 23 ms 5224 KB Partially correct
26 Correct 23 ms 5164 KB Output is correct
27 Correct 25 ms 5036 KB Output is correct
28 Correct 23 ms 5420 KB Output is correct
29 Correct 23 ms 4792 KB Output is correct
30 Partially correct 22 ms 5132 KB Partially correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 6928 KB Output is correct
2 Incorrect 43 ms 7128 KB Output isn't correct
3 Halted 0 ms 0 KB -