답안 #55091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55091 2018-07-06T03:50:19 Z ainta(#1558) Dungeon 2 (JOI16_dungeon2) C++11
100 / 100
27 ms 1412 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_], v[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++) {
		if (pE[a] == i)continue;
		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:46:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < Ch[a].size(); i++) {
                  ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 568 KB Output is correct
3 Correct 4 ms 568 KB Output is correct
4 Correct 3 ms 572 KB Output is correct
5 Correct 3 ms 572 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 772 KB Output is correct
8 Correct 2 ms 772 KB Output is correct
9 Correct 2 ms 772 KB Output is correct
10 Correct 3 ms 772 KB Output is correct
11 Correct 2 ms 772 KB Output is correct
12 Correct 3 ms 896 KB Output is correct
13 Correct 2 ms 896 KB Output is correct
14 Correct 2 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 2 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 2 ms 896 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 2 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 2 ms 896 KB Output is correct
12 Correct 3 ms 896 KB Output is correct
13 Correct 3 ms 896 KB Output is correct
14 Correct 2 ms 896 KB Output is correct
15 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1148 KB Output is correct
2 Correct 12 ms 1308 KB Output is correct
3 Correct 15 ms 1308 KB Output is correct
4 Correct 26 ms 1412 KB Output is correct
5 Correct 3 ms 1412 KB Output is correct
6 Correct 6 ms 1412 KB Output is correct
7 Correct 23 ms 1412 KB Output is correct
8 Correct 15 ms 1412 KB Output is correct
9 Correct 21 ms 1412 KB Output is correct
10 Correct 15 ms 1412 KB Output is correct
11 Correct 13 ms 1412 KB Output is correct
12 Correct 14 ms 1412 KB Output is correct
13 Correct 14 ms 1412 KB Output is correct
14 Correct 20 ms 1412 KB Output is correct
15 Correct 22 ms 1412 KB Output is correct
16 Correct 9 ms 1412 KB Output is correct
17 Correct 27 ms 1412 KB Output is correct
18 Correct 25 ms 1412 KB Output is correct
19 Correct 25 ms 1412 KB Output is correct