답안 #55088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55088 2018-07-06T03:44:34 Z ainta(#1558) Dungeon 2 (JOI16_dungeon2) C++11
90 / 100
40 ms 2904 KB
#include "dungeon2.h"
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define N_ 210

int cnt = 0, par[N_], pE[N_], C[N_], S[N_][N_], E[N_][N_];
vector<int>Up[N_], Ch[N_], ChN[N_];

void DFS() {
	int a = ++cnt;
	C[a] = NumberOfRoads();
	pE[a] = LastRoad();
	int i;
	for (i = 1; i <= C[a]; i++) {
		Move(i, 2);
		int c = Color();
		if (c == 1) {
			par[cnt + 1] = a;
			Ch[a].push_back(i);
			ChN[a].push_back(cnt + 1);
			DFS();
		}
		else if (c == 2) {
			Up[a].push_back(i);
			Move(LastRoad(), 2);
		}
		else {
			Move(LastRoad(), 3);
		}
	}
	if (pE[a] != -1) {
		Move(pE[a], 3);
	}
}
int po[6], res[N_];

void Go(int a, int K) {
	for (auto &x : Up[a]) {
		Move(x, 1);
		S[a][x] += (Color()-1)*K;
		Move(LastRoad(), Color());
	}
	for (int i = 0; i < Ch[a].size(); i++) {
		Move(Ch[a][i], (a / K) % 3 + 1);
		Go(ChN[a][i], K);
	}
	if (pE[a] != -1)Move(pE[a], (a / K) % 3 + 1);
}

void Inspect(int R)
{
	DFS();
	po[0] = 1;
	int i, j, k;
	for (i = 0; i < 5; i++)po[i + 1] = po[i] * 3;
	for (i = 0; i < 5; i++) {
		Go(1, po[i]);
	}
	for (i = 1; i <= cnt; i++)for (j = 1; j <= cnt; j++) {
		if (i != j)E[i][j] = 1e9;
		else E[i][j] = 0;
	}
	for (i = 2; i <= cnt; i++) {
		E[i][par[i]] = E[par[i]][i] = 1;
	}
	for (i = 1; i <= cnt; i++) {
		for (auto &x : Up[i]) {
			E[i][S[i][x]] = E[S[i][x]][i] = 1;
		}
	}
	for (k = 1; k <= cnt; k++)for (i = 1; i <= cnt; i++)for (j = 1; j <= cnt; j++)E[i][j] = min(E[i][j], E[i][k] + E[k][j]);
	for (i = 1; i <= cnt; i++)for (j = i + 1; j <= cnt; j++) {
		res[E[i][j]]++;
	}
	for (i = 1; i <= R; i++) {
		Answer(i, res[i]);
	}
}

Compilation message

dungeon2.cpp: In function 'void Go(int, int)':
dungeon2.cpp:45:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < Ch[a].size(); i++) {
                  ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 472 KB Output is correct
2 Correct 2 ms 672 KB Output is correct
3 Correct 4 ms 672 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 3 ms 812 KB Output is correct
8 Correct 3 ms 816 KB Output is correct
9 Correct 2 ms 876 KB Output is correct
10 Correct 4 ms 944 KB Output is correct
11 Correct 2 ms 944 KB Output is correct
12 Correct 3 ms 944 KB Output is correct
13 Correct 2 ms 952 KB Output is correct
14 Correct 2 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1016 KB Output is correct
2 Correct 2 ms 1032 KB Output is correct
3 Correct 2 ms 1032 KB Output is correct
4 Correct 2 ms 1032 KB Output is correct
5 Correct 2 ms 1032 KB Output is correct
6 Correct 3 ms 1032 KB Output is correct
7 Correct 3 ms 1032 KB Output is correct
8 Correct 3 ms 1032 KB Output is correct
9 Correct 3 ms 1032 KB Output is correct
10 Correct 2 ms 1032 KB Output is correct
11 Correct 2 ms 1032 KB Output is correct
12 Correct 2 ms 1032 KB Output is correct
13 Correct 3 ms 1032 KB Output is correct
14 Correct 4 ms 1032 KB Output is correct
15 Correct 3 ms 1032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 17 ms 1492 KB Partially correct
2 Partially correct 15 ms 1496 KB Partially correct
3 Partially correct 15 ms 1632 KB Partially correct
4 Partially correct 29 ms 1940 KB Partially correct
5 Partially correct 3 ms 1940 KB Partially correct
6 Partially correct 5 ms 1940 KB Partially correct
7 Partially correct 13 ms 1940 KB Partially correct
8 Partially correct 17 ms 1972 KB Partially correct
9 Partially correct 15 ms 1992 KB Partially correct
10 Partially correct 15 ms 1992 KB Partially correct
11 Partially correct 16 ms 2020 KB Partially correct
12 Partially correct 19 ms 2020 KB Partially correct
13 Partially correct 18 ms 2048 KB Partially correct
14 Partially correct 22 ms 2048 KB Partially correct
15 Partially correct 20 ms 2048 KB Partially correct
16 Partially correct 9 ms 2048 KB Partially correct
17 Partially correct 40 ms 2424 KB Partially correct
18 Partially correct 26 ms 2676 KB Partially correct
19 Partially correct 26 ms 2904 KB Partially correct