Submission #55837

# Submission time Handle Problem Language Result Execution time Memory
55837 2018-07-09T05:43:21 Z 윤교준(#1564) None (JOI16_dungeon2) C++11
Compilation error
0 ms 0 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("");
		}
		printf("TEST=%d\n", IAmHere());
	}


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

		if(debug) {
			printf("TEST%d : =%d\n", i, IAmHere());
		}
	}

	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]);
}

Compilation message

dungeon2.cpp: In function 'void Inspect(int)':
dungeon2.cpp:86:23: error: 'IAmHere' was not declared in this scope
   printf("TEST=%d\n", IAmHere());
                       ^~~~~~~
dungeon2.cpp:95:32: error: 'IAmHere' was not declared in this scope
    printf("TEST%d : =%d\n", i, IAmHere());
                                ^~~~~~~