Submission #55840

# Submission time Handle Problem Language Result Execution time Memory
55840 2018-07-09T05:44:27 Z 윤교준(#1564) None (JOI16_dungeon2) C++11
90 / 100
52 ms 3456 KB
#include "dungeon2.h"
#include <bits/stdc++.h>
#define pb push_back
#define sz(V) ((int)(V).size())
#define upmin(a,b) (a)=min((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;
const bool debug = 0;

const int MAXN = 205;

vector<int> G[MAXN];
vector<vector<int>> GC[MAXN];

int D[MAXN][MAXN];
int Ans[MAXN];

int N, K, CDG;

int getColor(int n, int k) {
	for(; k; k--) n /= 3;
	return n % 3 + 1;
}

int f(int pv) {
	const int idx = ++N;
	const int dg = NumberOfRoads();
	const int li = LastRoad();
	G[idx].resize(dg+1, 0);
	GC[idx].resize(dg+1, vector<int>(6, 0));

	if(1 <= li && 1 <= pv) {
		G[idx][li] = pv;
	}

	for(int i = 1; i <= dg; i++) {
		if(G[idx][i]) continue;

		Move(i, 2);
		if(2 == Color()) {
			G[idx][i] = -1;
			Move(LastRoad(), 2);
			continue;
		}

		G[idx][i] = f(idx);
	}

	if(1 <= li) Move(li, 2);
	return idx;
}

void g(int idx, int pv) {
	const int dg = NumberOfRoads();
	const int col = getColor(idx, CDG);
	const int li = LastRoad();

	for(int i = 1; i <= dg; i++) {
		if(pv == G[idx][i]) continue;
		if(1 <= G[idx][i]) {
			Move(i, col);
			g(G[idx][i], idx);
			continue;
		}

		Move(i, col);
		GC[idx][i][CDG] = Color();
		Move(LastRoad(), Color());
	}

	if(1 != idx && 1 <= li)
		Move(li, col);
}

void Inspect(int K) {
	::K = K;
	f(-1);

	if(debug) {
		printf("N=%d\n", N);
		for(int i = 1; i <= N; i++) {
			printf("%dG : ", i);
			for(int v : G[i]) printf("%d ", v);
			puts("");
		}
	}


	for(int i = 0; i < 5; i++) {
		CDG = i;
		g(1, -2);
	}

	for(int i = 1; i <= N; i++) {
		for(int j = 1; j < sz(G[i]); j++) {
			if(1 <= G[i][j]) continue;

			int ret = 0;
			for(int k = 4; 0 <= k; k--) {
				ret = ret * 3 + (GC[i][j][k] - 1);
			}
			G[i][j] = ret;
		}
	}

	if(debug) {
		puts("FINAL");
		for(int i = 1; i <= N; i++) {
			printf("%dG : ", i);
			for(int v : G[i]) printf("%d ", v);
			puts("");
		}
	}

	for(int i = 1; i <= N; i++) fill(D[i], D[i]+N+1, INF);
	for(int i = 1; i <= N; i++) D[i][i] = 0;
	for(int i = 1; i <= N; i++) {
		for(int v : G[i]) {
			if(v < 1 || N < v) continue;
			D[i][v] = D[v][i] = 1;
		}
	}

	for(int k = 1; k <= N; k++) for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++)
		upmin(D[i][j], D[i][k] + D[k][j]);
	
	for(int i = 1; i <= N; i++) for(int j = i+1; j <= N; j++)
		Ans[D[i][j]]++;
	
	for(int i = 1; i <= K; i++)
		Answer(i, Ans[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 520 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 3 ms 644 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 3 ms 720 KB Output is correct
9 Correct 3 ms 720 KB Output is correct
10 Correct 3 ms 828 KB Output is correct
11 Correct 3 ms 828 KB Output is correct
12 Correct 3 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 3 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 828 KB Output is correct
2 Correct 2 ms 828 KB Output is correct
3 Correct 3 ms 828 KB Output is correct
4 Correct 3 ms 828 KB Output is correct
5 Correct 3 ms 828 KB Output is correct
6 Correct 3 ms 828 KB Output is correct
7 Correct 3 ms 828 KB Output is correct
8 Correct 3 ms 828 KB Output is correct
9 Correct 3 ms 828 KB Output is correct
10 Correct 2 ms 828 KB Output is correct
11 Correct 3 ms 828 KB Output is correct
12 Correct 2 ms 876 KB Output is correct
13 Correct 2 ms 876 KB Output is correct
14 Correct 3 ms 876 KB Output is correct
15 Correct 4 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1148 KB Output is correct
2 Partially correct 15 ms 1148 KB Partially correct
3 Partially correct 18 ms 1276 KB Partially correct
4 Partially correct 52 ms 3456 KB Partially correct
5 Partially correct 2 ms 3456 KB Partially correct
6 Partially correct 7 ms 3456 KB Partially correct
7 Partially correct 14 ms 3456 KB Partially correct
8 Partially correct 12 ms 3456 KB Partially correct
9 Partially correct 13 ms 3456 KB Partially correct
10 Partially correct 12 ms 3456 KB Partially correct
11 Partially correct 13 ms 3456 KB Partially correct
12 Partially correct 15 ms 3456 KB Partially correct
13 Partially correct 15 ms 3456 KB Partially correct
14 Correct 12 ms 3456 KB Output is correct
15 Partially correct 14 ms 3456 KB Partially correct
16 Partially correct 12 ms 3456 KB Partially correct
17 Partially correct 47 ms 3456 KB Partially correct
18 Partially correct 39 ms 3456 KB Partially correct
19 Partially correct 42 ms 3456 KB Partially correct