#include "dungeon2.h"
#include <bits/stdc++.h>
#define MAX 250
using namespace std;
typedef pair<int, int> pii;
vector<pii> tree[MAX], up[MAX];
vector<int> backe[MAX], adj[MAX];
int prt[MAX];
int prtl[MAX];
int ans[MAX];
int dist[MAX][MAX];
int pow3[6] = { 1, 3, 9, 27, 81, 243 };
int cnt = 1;
void dfs(int x = 1, int p = 0, int pv = -1) {
prt[x] = p;
prtl[x] = pv;
int deg = NumberOfRoads();
int i;
for (i = 1; i <= deg; i++) if (i != pv) {
Move(i, 2);
if (Color() == 2) up[x].emplace_back(0, i), Move(LastRoad(), 2);
else if (Color() == 3) Move(LastRoad(), Color());
else if (Color() == 1) cnt++, tree[x].emplace_back(cnt, i), dfs(cnt, x, LastRoad());
}
if (x > 1) Move(pv, 3);
}
int getv(int x, int k) {
while (k--) x /= 3;
return (x % 3) + 1;
}
void addv(int x, int k) {
for (auto& [v, e] : up[x]) {
Move(e, getv(x, k));
v += pow3[k] * (Color() - 1);
Move(LastRoad(), Color());
}
for (auto& [v, e] : tree[x]) {
Move(e, getv(x, k));
addv(v, k);
}
if (x > 1) Move(prtl[x], getv(x, k));
}
void getdis(int x) {
queue<int> q;
q.push(x);
while (q.size()) {
int t = q.front();
q.pop();
for (auto v : adj[t]) {
if (!dist[x][v]) {
dist[x][v] = dist[x][t] + 1;
q.push(v);
}
}
}
}
void Inspect(int R) {
dfs();
for (int k = 0; k < 6; k++) addv(1, k);
int i, j;
for (i = 1; i <= cnt; i++) for (auto& [v, e] : up[i]) adj[i].push_back(v), adj[v].push_back(i);
for (i = 1; i <= cnt; i++) for (auto& [v, e] : tree[i]) adj[i].push_back(v), adj[v].push_back(i);
for (i = 1; i <= cnt; i++) getdis(i);
for (i = 1; i <= cnt; i++) for (j = i + 1; j <= cnt; j++) ans[dist[i][j]]++;
for (i = 1; i <= R; i++) Answer(i, ans[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
464 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
464 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
464 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
464 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
852 KB |
Partially correct |
2 |
Partially correct |
2 ms |
852 KB |
Partially correct |
3 |
Partially correct |
3 ms |
988 KB |
Partially correct |
4 |
Partially correct |
19 ms |
1604 KB |
Partially correct |
5 |
Partially correct |
1 ms |
468 KB |
Partially correct |
6 |
Partially correct |
1 ms |
724 KB |
Partially correct |
7 |
Partially correct |
1 ms |
852 KB |
Partially correct |
8 |
Partially correct |
2 ms |
852 KB |
Partially correct |
9 |
Partially correct |
2 ms |
980 KB |
Partially correct |
10 |
Partially correct |
2 ms |
852 KB |
Partially correct |
11 |
Partially correct |
2 ms |
976 KB |
Partially correct |
12 |
Partially correct |
3 ms |
984 KB |
Partially correct |
13 |
Partially correct |
4 ms |
1108 KB |
Partially correct |
14 |
Partially correct |
1 ms |
948 KB |
Partially correct |
15 |
Partially correct |
2 ms |
852 KB |
Partially correct |
16 |
Partially correct |
3 ms |
724 KB |
Partially correct |
17 |
Partially correct |
16 ms |
1656 KB |
Partially correct |
18 |
Partially correct |
15 ms |
1536 KB |
Partially correct |
19 |
Partially correct |
17 ms |
1620 KB |
Partially correct |