Submission #197808

# Submission time Handle Problem Language Result Execution time Memory
197808 2020-01-23T09:45:13 Z TAISA_ Amusement Park (JOI17_amusement_park) C++14
80 / 100
86 ms 5072 KB
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
static vector<vector<int>> G;
static vector<int> vis,dep,et;
static int md;
static void dfs(int i){
	vis[i]=1;
	md=max(md,dep[i]);
	et.push_back(i);
	for(auto &e:G[i]){
		if(vis[e]){
			continue;
		}
		dep[e]=dep[i]+1;
		dfs(e);
	}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
	G.resize(N);
	vis.resize(N);
	dep.resize(N);
	for(int i=0;i<M;i++){
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}
	dfs(0);
	if(md>=59){
		for(int i=0;i<N;i++){
			dep[i]%=60;
			MessageBoard(i,((X>>dep[i])&1));
		}
	}else{
		for(int i=0;i<N;i++){
			if(i<60){
				MessageBoard(et[i],((X>>i)&1));
			}else{
				MessageBoard(et[i],0);
			}
		}
	}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
static vector<vector<int>> G,g;
static vector<int> vis,dep,et,md,par,res;
static int dfs(int i){
	vis[i]=1;
	md[i]=dep[i];
	et.push_back(i);
	for(auto &e:G[i]){
		if(vis[e]){
			continue;
		}
		g[i].push_back(e);
		dep[e]=dep[i]+1;
		par[e]=i;
		md[i]=max(md[i],dfs(e));
	}
	return md[i];
}
static int cnt;
static void dfs2(int i){
	vis[i]=1;
	cnt++;
	if(cnt==60){
		return;
	}
	for(auto &e:G[i]){
		if(vis[e]){
			continue;
		}
		res[e]=Move(e);
		dfs2(e);
		if(cnt==60){
			return;
		}
	}
	if(i>0){
		Move(par[i]);
	}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
	G.resize(N);
	g.resize(N);
	vis.resize(N);
	dep.resize(N);
	md.resize(N);
	for(int i=0;i<M;i++){
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}
	par.resize(N,-1);
	res.resize(N,-1);
	dfs(0);
	ll ans=0;
	res[P]=V;
	if(md[0]>=59){
		while(dep[P]%60>0){
			res[par[P]]=Move(par[P]);
			P=par[P];
		}
		vector<int> vs;
		if(md[P]-dep[P]<59){
			while(md[P]-dep[P]<59||dep[P]%60>0){
				res[par[P]]=Move(par[P]);
				vs.push_back(res[par[P]]);
				P=par[P];
			}
			reverse(vs.begin(),vs.end());
		}else{
			int r=P;
			while(P==r||dep[P]%60>0){
				vs.push_back(res[P]);
				if(g[P].empty()){
					break;
				}
				for(auto &e:g[P]){
					if(md[e]-dep[r]>=59){
						res[e]=Move(e);
						P=e;
						break;
					}
				}
			}
		}
		for(int i=0;i<60;i++){
			if(vs[i]){
				ans+=(1LL<<i);
			}
		}		
	}else{
		while(P>0){
			res[par[P]]=Move(par[P]);
			P=par[P];
		}
		vis.assign(N,0);
		cnt=0;
		dfs2(0);
		for(int i=0;i<60;i++){
			if(res[et[i]]){
				ans+=(1LL<<i);
			}
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 888 KB Output is correct
2 Correct 4 ms 952 KB Output is correct
3 Correct 5 ms 900 KB Output is correct
4 Correct 5 ms 888 KB Output is correct
5 Correct 5 ms 884 KB Output is correct
6 Correct 4 ms 920 KB Output is correct
7 Correct 4 ms 936 KB Output is correct
8 Correct 4 ms 944 KB Output is correct
9 Correct 4 ms 764 KB Output is correct
10 Correct 4 ms 884 KB Output is correct
11 Correct 5 ms 1356 KB Output is correct
12 Correct 4 ms 884 KB Output is correct
13 Correct 4 ms 900 KB Output is correct
14 Correct 4 ms 900 KB Output is correct
15 Correct 4 ms 940 KB Output is correct
16 Correct 5 ms 900 KB Output is correct
17 Correct 4 ms 940 KB Output is correct
18 Correct 4 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 4888 KB Output is correct
2 Correct 34 ms 4840 KB Output is correct
3 Correct 35 ms 4884 KB Output is correct
4 Correct 20 ms 3524 KB Output is correct
5 Correct 22 ms 4080 KB Output is correct
6 Correct 22 ms 3988 KB Output is correct
7 Correct 22 ms 3768 KB Output is correct
8 Correct 22 ms 3904 KB Output is correct
9 Correct 22 ms 3896 KB Output is correct
10 Correct 19 ms 3536 KB Output is correct
11 Correct 19 ms 3580 KB Output is correct
12 Correct 20 ms 3368 KB Output is correct
13 Correct 20 ms 3368 KB Output is correct
14 Correct 19 ms 3288 KB Output is correct
15 Correct 86 ms 3900 KB Output is correct
16 Correct 22 ms 3568 KB Output is correct
17 Correct 20 ms 3512 KB Output is correct
18 Correct 20 ms 3524 KB Output is correct
19 Correct 22 ms 3512 KB Output is correct
20 Correct 17 ms 3908 KB Output is correct
21 Correct 18 ms 4052 KB Output is correct
22 Correct 22 ms 3648 KB Output is correct
23 Correct 22 ms 4024 KB Output is correct
24 Correct 22 ms 3768 KB Output is correct
25 Correct 22 ms 3852 KB Output is correct
26 Correct 22 ms 3760 KB Output is correct
27 Correct 22 ms 3904 KB Output is correct
28 Correct 22 ms 3896 KB Output is correct
29 Correct 20 ms 3640 KB Output is correct
30 Correct 20 ms 3640 KB Output is correct
31 Correct 4 ms 916 KB Output is correct
32 Correct 4 ms 760 KB Output is correct
33 Correct 4 ms 760 KB Output is correct
34 Correct 4 ms 636 KB Output is correct
35 Correct 6 ms 848 KB Output is correct
36 Correct 4 ms 892 KB Output is correct
37 Correct 4 ms 1004 KB Output is correct
38 Correct 4 ms 884 KB Output is correct
39 Correct 4 ms 892 KB Output is correct
40 Correct 4 ms 868 KB Output is correct
41 Correct 4 ms 884 KB Output is correct
42 Correct 4 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 836 KB Output is correct
2 Correct 4 ms 888 KB Output is correct
3 Correct 4 ms 836 KB Output is correct
4 Correct 6 ms 1524 KB Output is correct
5 Correct 6 ms 1432 KB Output is correct
6 Correct 6 ms 1452 KB Output is correct
7 Correct 7 ms 1524 KB Output is correct
8 Correct 6 ms 1296 KB Output is correct
9 Correct 18 ms 4544 KB Output is correct
10 Correct 18 ms 4672 KB Output is correct
11 Correct 18 ms 4664 KB Output is correct
12 Correct 4 ms 888 KB Output is correct
13 Correct 4 ms 752 KB Output is correct
14 Correct 4 ms 880 KB Output is correct
15 Correct 3 ms 880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 4872 KB Output is correct
2 Correct 34 ms 4944 KB Output is correct
3 Correct 35 ms 5072 KB Output is correct
4 Correct 20 ms 3384 KB Output is correct
5 Correct 22 ms 4600 KB Output is correct
6 Correct 22 ms 4136 KB Output is correct
7 Correct 22 ms 4136 KB Output is correct
8 Correct 22 ms 4056 KB Output is correct
9 Correct 22 ms 3880 KB Output is correct
10 Correct 20 ms 3884 KB Output is correct
11 Correct 25 ms 3884 KB Output is correct
12 Correct 20 ms 3476 KB Output is correct
13 Partially correct 20 ms 3660 KB Partially correct
14 Partially correct 20 ms 3772 KB Partially correct
15 Correct 22 ms 3888 KB Output is correct
16 Correct 24 ms 3788 KB Output is correct
17 Correct 28 ms 3764 KB Output is correct
18 Partially correct 22 ms 3772 KB Partially correct
19 Partially correct 22 ms 3992 KB Partially correct
20 Correct 17 ms 4136 KB Output is correct
21 Correct 19 ms 4348 KB Output is correct
22 Correct 24 ms 4252 KB Output is correct
23 Correct 23 ms 4016 KB Output is correct
24 Correct 22 ms 4016 KB Output is correct
25 Correct 23 ms 4152 KB Output is correct
26 Correct 22 ms 4008 KB Output is correct
27 Correct 22 ms 4136 KB Output is correct
28 Correct 22 ms 4144 KB Output is correct
29 Correct 36 ms 3716 KB Output is correct
30 Correct 20 ms 3868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4820 KB Output is correct
2 Correct 35 ms 4944 KB Output is correct
3 Correct 34 ms 4988 KB Output is correct
4 Correct 22 ms 3520 KB Output is correct
5 Correct 22 ms 4420 KB Output is correct
6 Correct 22 ms 3768 KB Output is correct
7 Correct 23 ms 3640 KB Output is correct
8 Correct 22 ms 3908 KB Output is correct
9 Correct 22 ms 3932 KB Output is correct
10 Correct 19 ms 3520 KB Output is correct
11 Correct 20 ms 3616 KB Output is correct
12 Correct 24 ms 3604 KB Output is correct
13 Incorrect 20 ms 3468 KB Output isn't correct
14 Halted 0 ms 0 KB -