답안 #26129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26129 2017-06-28T05:39:34 Z khsoo01 Dungeon 2 (JOI16_dungeon2) C++11
100 / 100
23 ms 2948 KB
#include "dungeon2.h"
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int inf = 1e9;

int n, bck[205], cur = 1;
int dist[205][205], ans[205];

vector<pii> adj[205];

void init (int C, int P) {
	adj[C].resize(NumberOfRoads()+1);
	if(P) {
		bck[C] = LastRoad();
		adj[C][bck[C]] = pii(P, 1);
	}
	for(int i=1;i<adj[C].size();i++) {
		if(i == bck[C]) continue;
		Move(i, 2);
		if(Color() != 1) {
			adj[C][i] = pii(0, Color());
			Move(LastRoad(), Color());
		}
		else {
			adj[C][i] = pii(++n, 0);
			init(n, C);
		}
	}
	if(P) Move(bck[C], 3);
}

void getbit (int C, int P) {
	for(int i=1;i<adj[C].size();i++) {
		if(adj[C][i].Y == 0) {
			Move(i, (C/cur)%3+1);
			getbit(adj[C][i].X, C);
		}
		if(adj[C][i].Y == 2) {
			Move(i, 1);
			adj[C][i].X += (Color()-1)*cur;
			Move(LastRoad(), Color());
		}
	}
	if(P) Move(bck[C], 1);
}

void Inspect(int R)
{
	init(++n, 0);
	for(int i=0;i<5;i++) {
		getbit(1, 0);
		cur *= 3;
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) dist[i][j] = inf;
		dist[i][i] = 0;
	}
	for(int i=1;i<=n;i++) for(auto &T : adj[i]) {
		int A, B; tie(A, B) = T;
		if(B % 2) continue;
		dist[i][A] = 1; dist[A][i] = 1;
	}
	for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) {
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) {
		if(dist[i][j] <= R) ans[dist[i][j]]++;
	}
	for(int i=1;i<=R;i++) Answer(i, ans[i]);
}

Compilation message

dungeon2.cpp: In function 'void init(int, int)':
dungeon2.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<adj[C].size();i++) {
               ^
dungeon2.cpp: In function 'void getbit(int, int)':
dungeon2.cpp:36:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<adj[C].size();i++) {
               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2684 KB Output is correct
2 Correct 0 ms 2684 KB Output is correct
3 Correct 0 ms 2684 KB Output is correct
4 Correct 0 ms 2684 KB Output is correct
5 Correct 0 ms 2684 KB Output is correct
6 Correct 0 ms 2684 KB Output is correct
7 Correct 0 ms 2684 KB Output is correct
8 Correct 0 ms 2684 KB Output is correct
9 Correct 0 ms 2684 KB Output is correct
10 Correct 0 ms 2684 KB Output is correct
11 Correct 0 ms 2684 KB Output is correct
12 Correct 0 ms 2684 KB Output is correct
13 Correct 0 ms 2684 KB Output is correct
14 Correct 0 ms 2684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2684 KB Output is correct
2 Correct 0 ms 2684 KB Output is correct
3 Correct 0 ms 2684 KB Output is correct
4 Correct 0 ms 2684 KB Output is correct
5 Correct 0 ms 2684 KB Output is correct
6 Correct 0 ms 2684 KB Output is correct
7 Correct 0 ms 2684 KB Output is correct
8 Correct 0 ms 2684 KB Output is correct
9 Correct 0 ms 2684 KB Output is correct
10 Correct 0 ms 2684 KB Output is correct
11 Correct 0 ms 2684 KB Output is correct
12 Correct 0 ms 2684 KB Output is correct
13 Correct 0 ms 2684 KB Output is correct
14 Correct 0 ms 2684 KB Output is correct
15 Correct 0 ms 2684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2684 KB Output is correct
2 Correct 9 ms 2684 KB Output is correct
3 Correct 9 ms 2684 KB Output is correct
4 Correct 23 ms 2948 KB Output is correct
5 Correct 0 ms 2684 KB Output is correct
6 Correct 3 ms 2684 KB Output is correct
7 Correct 9 ms 2684 KB Output is correct
8 Correct 9 ms 2684 KB Output is correct
9 Correct 9 ms 2684 KB Output is correct
10 Correct 9 ms 2684 KB Output is correct
11 Correct 9 ms 2684 KB Output is correct
12 Correct 9 ms 2684 KB Output is correct
13 Correct 13 ms 2816 KB Output is correct
14 Correct 9 ms 2684 KB Output is correct
15 Correct 9 ms 2684 KB Output is correct
16 Correct 3 ms 2816 KB Output is correct
17 Correct 23 ms 2948 KB Output is correct
18 Correct 19 ms 2948 KB Output is correct
19 Correct 19 ms 2948 KB Output is correct