Submission #55851

# Submission time Handle Problem Language Result Execution time Memory
55851 2018-07-09T05:53:52 Z 김현수(#2092) None (JOI16_dungeon2) C++11
100 / 100
23 ms 1536 KB
#include "dungeon2.h"
#include<bits/stdc++.h>
using namespace std;

const int N = 205, inf = 1e9;

int n, bas = 1, dis[N][N], ans[N];

vector<int> adj[N], bck[N];

void build (int I, int P) {
	int K = NumberOfRoads();
	int L = LastRoad();
	for(int i=0;i<K;i++) {
		if(i+1 == L) {
			adj[I].push_back(P);
			bck[I].push_back(2);
			continue;
		}
		Move(i+1, 2);
		if(Color() > 1) {
			adj[I].push_back(0);
			bck[I].push_back(Color() - 1);
			Move(LastRoad(), Color());
		}
		else {
			adj[I].push_back(++n);
			bck[I].push_back(0);
			build(n, I);
		}
	}
	if(~L) Move(L, 3);
}

void seek (int I) {
	int K = adj[I].size();
	int V = I / bas % 3;
	int L = LastRoad();
	for(int i=0;i<K;i++) {
		if(bck[I][i] == 2) continue;
		Move(i+1, V+1);
		if(bck[I][i]) {
			adj[I][i] += (Color()-1) * bas;
			Move(LastRoad(), Color());
		}
		else {
			seek(adj[I][i]);
		}
	}
	if(I != 1) Move(L, 1);
}

void Inspect(int R)
{
	build(++n, 0);
	for(int i=0;i<5;i++) {
		seek(1);
		bas *= 3;
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			dis[i][j] = inf;
		}
		dis[i][i] = 0;
	}
	for(int i=1;i<=n;i++) {
		for(auto &T : adj[i]) {
			if(!T) continue;
			dis[i][T] = 1;
			dis[T][i] = 1;
		}
	}
	for(int k=1;k<=n;k++) {
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=n;j++) {
				if(dis[i][k] + dis[k][j] < dis[i][j]) {
					dis[i][j] = dis[i][k] + dis[k][j];
				}
			}
		}
	}
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			ans[dis[i][j]]++;
		}
	}
	for(int i=1;i<=R;i++) {
		Answer(i, ans[i]);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 520 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 3 ms 676 KB Output is correct
7 Correct 4 ms 748 KB Output is correct
8 Correct 3 ms 748 KB Output is correct
9 Correct 3 ms 876 KB Output is correct
10 Correct 3 ms 876 KB Output is correct
11 Correct 3 ms 876 KB Output is correct
12 Correct 3 ms 876 KB Output is correct
13 Correct 4 ms 876 KB Output is correct
14 Correct 4 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 876 KB Output is correct
2 Correct 4 ms 876 KB Output is correct
3 Correct 3 ms 876 KB Output is correct
4 Correct 3 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 3 ms 876 KB Output is correct
8 Correct 4 ms 876 KB Output is correct
9 Correct 3 ms 876 KB Output is correct
10 Correct 2 ms 876 KB Output is correct
11 Correct 3 ms 876 KB Output is correct
12 Correct 3 ms 876 KB Output is correct
13 Correct 3 ms 876 KB Output is correct
14 Correct 3 ms 876 KB Output is correct
15 Correct 2 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1208 KB Output is correct
2 Correct 12 ms 1208 KB Output is correct
3 Correct 14 ms 1208 KB Output is correct
4 Correct 22 ms 1532 KB Output is correct
5 Correct 3 ms 1532 KB Output is correct
6 Correct 5 ms 1532 KB Output is correct
7 Correct 12 ms 1532 KB Output is correct
8 Correct 15 ms 1532 KB Output is correct
9 Correct 18 ms 1532 KB Output is correct
10 Correct 13 ms 1532 KB Output is correct
11 Correct 15 ms 1532 KB Output is correct
12 Correct 12 ms 1532 KB Output is correct
13 Correct 15 ms 1532 KB Output is correct
14 Correct 12 ms 1532 KB Output is correct
15 Correct 16 ms 1532 KB Output is correct
16 Correct 6 ms 1532 KB Output is correct
17 Correct 23 ms 1536 KB Output is correct
18 Correct 22 ms 1536 KB Output is correct
19 Correct 22 ms 1536 KB Output is correct