답안 #55991

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55991 2018-07-09T09:36:16 Z 김세빈(#1563) Dungeon 2 (JOI16_dungeon2) C++11
44 / 100
51 ms 1804 KB
#include "dungeon2.h"

#include <bits/stdc++.h>

using namespace std;

int N[2222][222], T[222][222];
int P[222], D[222], K[222];
vector <int> V[222];
int n;

void dfs(int p, int r, int id)
{
	int i;
	
	D[p] = NumberOfRoads();
	T[p][id] = r;
	N[p][r] = id;
	P[p] = r;
	
	for(i=1;i<=D[p];i++){
		if(i == id) continue;
		
		Move(i, 2);
		if(Color() != 1){
			Move(LastRoad(), 2);
		}
		else{
			T[p][i] = ++n;
			N[p][n] = i;
			V[p].push_back(n);
			dfs(n, p, LastRoad());
		}
	}
	
	if(id) Move(id, 2);
}

void dfs2(int p, int r)
{
	int i, j, t;
	
	for(auto t: V[p]){
		Move(N[p][t], 2);
		dfs2(t, p);
	}
	
	for(i=1;i<=D[p];i++){
		if(!T[p][i]){
			Move(i, 2);
			Move(t = LastRoad(), 3);
			
			for(j=p;;){
				Move(N[j][P[j]], 2); j = P[j];
				if(Color() == 3) break;
			}
			
			T[j][t] = p;
			N[j][p] = t;
			Move(t, 2);
			
			T[p][i] = j;
			N[p][j] = i;
		}
	}
	
	if(p != 1) Move(N[p][P[p]], 2);
}

void Inspect(int R)
{
	int i, j, k;
	
	n ++;
	dfs(1, 0, 0);
	
	dfs2(1, 0);
	
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(N[i][j]) N[i][j] = 1;
			else N[i][j] = 1e6;
		}
	}
	
	for(k=1;k<=n;k++){
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				N[i][j] = min(N[i][j], N[i][k] + N[k][j]);
			}
		}
	}
	
	for(i=1;i<=n;i++){
		for(j=1;j<i;j++){
			K[N[i][j]] ++;
		}
	}
	
	for(i=1;i<=R;i++){
		Answer(i, K[i]);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 4 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
8 Correct 4 ms 748 KB Output is correct
9 Correct 3 ms 748 KB Output is correct
10 Correct 4 ms 788 KB Output is correct
11 Correct 3 ms 836 KB Output is correct
12 Correct 4 ms 840 KB Output is correct
13 Correct 3 ms 840 KB Output is correct
14 Correct 4 ms 840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 840 KB Output is correct
2 Correct 4 ms 840 KB Output is correct
3 Correct 3 ms 840 KB Output is correct
4 Correct 3 ms 840 KB Output is correct
5 Correct 3 ms 840 KB Output is correct
6 Correct 3 ms 840 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Correct 4 ms 936 KB Output is correct
9 Correct 3 ms 936 KB Output is correct
10 Correct 3 ms 936 KB Output is correct
11 Correct 5 ms 936 KB Output is correct
12 Correct 4 ms 936 KB Output is correct
13 Correct 4 ms 936 KB Output is correct
14 Correct 3 ms 936 KB Output is correct
15 Correct 3 ms 936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1480 KB Output is correct
2 Partially correct 17 ms 1488 KB Partially correct
3 Partially correct 20 ms 1492 KB Partially correct
4 Incorrect 51 ms 1804 KB Output isn't correct
5 Halted 0 ms 0 KB -