답안 #69342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69342 2018-08-20T14:37:39 Z IvanC Amusement Park (JOI17_amusement_park) C++17
78 / 100
65 ms 31504 KB
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 10011;
const int MOD = 60;

static vector<int> grafo[MAXN],digitos;
static int dfs_num[MAXN],dfsCount;

static void dfs(int v){

	dfs_num[v] = dfsCount % MOD;
	dfsCount++;

	for(int u : grafo[v]){
		if(dfs_num[u] != -1) continue;
		dfs(u);
	}

}

void Joi(int N, int M, int A[], int B[], long long X, int T){
	
	memset(dfs_num,-1,sizeof(dfs_num));
	dfsCount = 0;
	for(int i = 0;i<N;i++) grafo[i].clear();
	digitos.clear();

	for(int i = 0;i<MOD;i++){
		if((1LL << i) & X)	digitos.push_back(1);
		else digitos.push_back(0);
	}

	for(int i = 0;i<M;i++){
		grafo[A[i]].push_back(B[i]);
		grafo[B[i]].push_back(A[i]);
	}	

	dfs(0);

	for(int i = 0; i < N; i++){	
		MessageBoard(i, digitos[dfs_num[i]]);
	}

}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 10011;
const int MOD = 60;

static deque<int> grafo[MAXN],tree[MAXN];
static int digitos[MOD],freq[MOD],distintos,processado[MAXN],dfsCount,dfs_num[MAXN],qual_digito[MAXN],pai[MAXN];

static void add_number(int x){
	if(freq[x] == 0) distintos++;
	freq[x]++;
}

static void add_vertex(int v){
	digitos[dfs_num[v]] = qual_digito[v];
	add_number(dfs_num[v]);
}

static void dfs(int v){

	dfs_num[v] = dfsCount % MOD;
	dfsCount++;

	for(int u : grafo[v]){
		if(dfs_num[u] != -1) continue;
		pai[u] = v;
		tree[v].push_back(u);
		dfs(u);
	}

}

static void find_ans(int v,int st){

	processado[v] = 1;
	add_vertex(v);
	if(distintos == MOD) return;

	deque<int> temp;

	while(st != -1 && tree[v].front() != st){
		temp.push_front(tree[v].front());
		tree[v].pop_front();
	}

	for(int u : temp) tree[v].push_back(u);
	temp.clear();

	for(int u : tree[v]){
		if(distintos == MOD) return;
		if(processado[u]) continue;
		int davez = Move(u);
		qual_digito[u] = davez;
		find_ans(u,-1);
		if(distintos == MOD) return;
		Move(v);
	}

	if(distintos != MOD){
		int davez = Move(pai[v]);
		qual_digito[pai[v]] = davez;
		find_ans(pai[v],v);
	}

}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {

	memset(dfs_num,-1,sizeof(dfs_num));
	memset(processado,0,sizeof(processado));
	memset(freq,0,sizeof(freq));
	dfsCount = 0;
	distintos = 0;
	for(int i = 0;i<N;i++) grafo[i].clear();

	for(int i = 0;i<M;i++){
		grafo[A[i]].push_back(B[i]);
		grafo[B[i]].push_back(A[i]);
	}	

	dfs(0);

	qual_digito[P] = V;

	find_ans(P,-1);

	long long ans = 0;
	for(int i = 0;i<MOD;i++) if(digitos[i]) ans += (1LL << i);

	return ans;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 14936 KB Output is correct
2 Correct 19 ms 28608 KB Output is correct
3 Correct 22 ms 28636 KB Output is correct
4 Correct 20 ms 28664 KB Output is correct
5 Correct 20 ms 28664 KB Output is correct
6 Correct 18 ms 28664 KB Output is correct
7 Correct 19 ms 28664 KB Output is correct
8 Correct 19 ms 28664 KB Output is correct
9 Correct 22 ms 28664 KB Output is correct
10 Correct 20 ms 28664 KB Output is correct
11 Correct 26 ms 28668 KB Output is correct
12 Correct 20 ms 28724 KB Output is correct
13 Correct 23 ms 28776 KB Output is correct
14 Correct 22 ms 28780 KB Output is correct
15 Correct 20 ms 28784 KB Output is correct
16 Correct 19 ms 28784 KB Output is correct
17 Correct 28 ms 28784 KB Output is correct
18 Correct 26 ms 28920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 30068 KB Output is correct
2 Correct 63 ms 31080 KB Output is correct
3 Correct 55 ms 31080 KB Output is correct
4 Correct 35 ms 31080 KB Output is correct
5 Correct 35 ms 31080 KB Output is correct
6 Correct 52 ms 31080 KB Output is correct
7 Correct 43 ms 31080 KB Output is correct
8 Correct 45 ms 31080 KB Output is correct
9 Correct 40 ms 31080 KB Output is correct
10 Correct 38 ms 31080 KB Output is correct
11 Correct 36 ms 31080 KB Output is correct
12 Correct 37 ms 31080 KB Output is correct
13 Correct 39 ms 31080 KB Output is correct
14 Correct 42 ms 31080 KB Output is correct
15 Correct 34 ms 31080 KB Output is correct
16 Correct 34 ms 31080 KB Output is correct
17 Correct 39 ms 31080 KB Output is correct
18 Correct 41 ms 31080 KB Output is correct
19 Correct 48 ms 31080 KB Output is correct
20 Correct 34 ms 31080 KB Output is correct
21 Correct 35 ms 31080 KB Output is correct
22 Correct 40 ms 31080 KB Output is correct
23 Correct 49 ms 31080 KB Output is correct
24 Correct 41 ms 31080 KB Output is correct
25 Correct 40 ms 31080 KB Output is correct
26 Correct 55 ms 31080 KB Output is correct
27 Correct 34 ms 31080 KB Output is correct
28 Correct 46 ms 31080 KB Output is correct
29 Correct 35 ms 31080 KB Output is correct
30 Correct 44 ms 31080 KB Output is correct
31 Correct 33 ms 31080 KB Output is correct
32 Correct 23 ms 31080 KB Output is correct
33 Correct 21 ms 31080 KB Output is correct
34 Correct 18 ms 31080 KB Output is correct
35 Correct 22 ms 31080 KB Output is correct
36 Correct 18 ms 31080 KB Output is correct
37 Correct 17 ms 31080 KB Output is correct
38 Correct 20 ms 31080 KB Output is correct
39 Correct 22 ms 31080 KB Output is correct
40 Correct 22 ms 31080 KB Output is correct
41 Correct 20 ms 31080 KB Output is correct
42 Correct 22 ms 31080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 31080 KB Output is correct
2 Correct 18 ms 31080 KB Output is correct
3 Correct 30 ms 31080 KB Output is correct
4 Correct 27 ms 31080 KB Output is correct
5 Correct 24 ms 31080 KB Output is correct
6 Correct 20 ms 31080 KB Output is correct
7 Correct 22 ms 31080 KB Output is correct
8 Correct 25 ms 31080 KB Output is correct
9 Correct 34 ms 31204 KB Output is correct
10 Correct 45 ms 31328 KB Output is correct
11 Correct 41 ms 31416 KB Output is correct
12 Correct 22 ms 31504 KB Output is correct
13 Correct 22 ms 31504 KB Output is correct
14 Correct 19 ms 31504 KB Output is correct
15 Correct 18 ms 31504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 31504 KB Output is correct
2 Partially correct 53 ms 31504 KB Partially correct
3 Correct 54 ms 31504 KB Output is correct
4 Correct 40 ms 31504 KB Output is correct
5 Correct 47 ms 31504 KB Output is correct
6 Correct 43 ms 31504 KB Output is correct
7 Correct 40 ms 31504 KB Output is correct
8 Correct 62 ms 31504 KB Output is correct
9 Correct 45 ms 31504 KB Output is correct
10 Correct 37 ms 31504 KB Output is correct
11 Correct 39 ms 31504 KB Output is correct
12 Correct 34 ms 31504 KB Output is correct
13 Correct 37 ms 31504 KB Output is correct
14 Correct 36 ms 31504 KB Output is correct
15 Correct 41 ms 31504 KB Output is correct
16 Correct 37 ms 31504 KB Output is correct
17 Correct 46 ms 31504 KB Output is correct
18 Correct 38 ms 31504 KB Output is correct
19 Correct 44 ms 31504 KB Output is correct
20 Correct 36 ms 31504 KB Output is correct
21 Correct 41 ms 31504 KB Output is correct
22 Correct 38 ms 31504 KB Output is correct
23 Correct 42 ms 31504 KB Output is correct
24 Correct 38 ms 31504 KB Output is correct
25 Correct 44 ms 31504 KB Output is correct
26 Correct 56 ms 31504 KB Output is correct
27 Correct 45 ms 31504 KB Output is correct
28 Correct 40 ms 31504 KB Output is correct
29 Correct 39 ms 31504 KB Output is correct
30 Correct 38 ms 31504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 31504 KB Output is correct
2 Correct 50 ms 31504 KB Output is correct
3 Correct 65 ms 31504 KB Output is correct
4 Incorrect 40 ms 31504 KB Output isn't correct
5 Halted 0 ms 0 KB -