#include "dungeon2.h"
#include <bits/stdc++.h>
using namespace std;
int d[201][201],matrix[201][201],mat[201][201],p[201],par[201],id=1,pw=1;
vector <int> ke[201],e[201],ve[201],ve2[201];
queue <int> q;
void dfs(int u){
p[u]=LastRoad();
int cnt=NumberOfRoads();
vector <int> V;
for (int i=1;i<=cnt;i++)
if (i!=p[u]){
Move(i,2);
if (Color()==3){
Move(LastRoad(),3);
continue;
}
if (Color()==1){
e[u].push_back(i);
id++;
ke[u].push_back(id);
par[id]=u;
dfs(id);
continue;
}
ve[u].push_back(i);
ve2[u].push_back(0);
Move(LastRoad(),2);
}
if (u!=1)
Move(p[u],3);
}
void dfs2(int u){
for (int i=0;i<ve[u].size();i++){
int v=ve[u][i];
Move(v,Color());
ve2[u][i]+=(Color()-1)*pw;
Move(LastRoad(),Color());
}
for (int i=0;i<ke[u].size();i++){
Move(e[u][i],u/pw%3+1);
dfs2(ke[u][i]);
}
if (u!=1)
Move(p[u],3);
}
void Inspect(int R){
dfs(1);
for (int i=0;i<5;i++){
dfs2(1);
pw*=3;
}
int n=id;
for (int i=1;i<=n;i++)
for (int j:ve2[i])
ke[i].push_back(j);
for (int i=1;i<=n;i++)
for (int j:ke[i])
ke[j].push_back(i);
memset(d,-1,sizeof(d));
int cnt=0;
for (int i=1;i<=n;i++){
cnt+=ke[i].size();
q.push(i);
d[i][i]=0;
while (!q.empty()){
int u=q.front();
q.pop();
for (int v:ke[u])
if (d[i][v]==-1){
d[i][v]=d[i][u]+1;
q.push(v);
}
}
}
for (int i=1;i<=R;i++){
int cnt=0;
for (int j=1;j<=n;j++)
for (int k=j+1;k<=n;k++)
cnt+=(d[j][k]==i);
Answer(i,cnt);
}
}
Compilation message
dungeon2.cpp: In function 'void dfs2(int)':
dungeon2.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for (int i=0;i<ve[u].size();i++){
| ~^~~~~~~~~~~~~
dungeon2.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for (int i=0;i<ke[u].size();i++){
| ~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
0 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
596 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
596 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
596 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
852 KB |
Output is correct |
2 |
Correct |
6 ms |
852 KB |
Output is correct |
3 |
Correct |
9 ms |
852 KB |
Output is correct |
4 |
Correct |
30 ms |
1364 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
3 ms |
724 KB |
Output is correct |
7 |
Correct |
5 ms |
852 KB |
Output is correct |
8 |
Correct |
5 ms |
852 KB |
Output is correct |
9 |
Correct |
5 ms |
852 KB |
Output is correct |
10 |
Correct |
6 ms |
924 KB |
Output is correct |
11 |
Correct |
6 ms |
928 KB |
Output is correct |
12 |
Correct |
5 ms |
852 KB |
Output is correct |
13 |
Correct |
8 ms |
1028 KB |
Output is correct |
14 |
Correct |
5 ms |
904 KB |
Output is correct |
15 |
Correct |
5 ms |
852 KB |
Output is correct |
16 |
Correct |
5 ms |
724 KB |
Output is correct |
17 |
Correct |
22 ms |
1364 KB |
Output is correct |
18 |
Correct |
18 ms |
1236 KB |
Output is correct |
19 |
Correct |
19 ms |
1356 KB |
Output is correct |