#include "coprobber.h"
// #include "grader.cpp"
#include <cstdio>
#include <queue>
#include <bitset>
#include <algorithm>
using namespace std;
int cop;
bool a[MAX_N][MAX_N];
vector<int> adjLis[MAX_N];
//sub2
int sidelength;
vector<vector<int>> solved, cnt;
vector<vector<bitset<500>>> run;
void solve(int cop, int robber, bool copturn=true){
//calling this function: robber caught
if(copturn){
for(int i: adjLis[robber]){
cnt[cop][i]-=run[cop][i][robber];
run[cop][i][robber]=false;
if(cnt[cop][i]==0)//no place to run
solve(cop, i, false);
}
}else{
for(int i: adjLis[cop]){
if(solved[i][robber]==-1){
solved[i][robber]=cop;
solve(i, robber, true);
}
}
if(solved[cop][robber]==-1){
solved[cop][robber]=cop;
solve(cop, robber, true);
}
}
}
int start(int n, bool A[MAX_N][MAX_N]){
for(int i=n; i--;)for(int j=n; j--;)
a[i][j]=A[i][j];
for(int i=n; i--;)for(int j=n; j--;){
if(a[i][j])
adjLis[i].push_back(j);
}
solved.assign(n, vector<int>(n, -1));
cnt.assign(n, vector<int>(n));
run.assign(n, vector<bitset<500>>(n));
for(int i=n; i--;)for(int j=n; j--;){
cnt[i][j]=adjLis[j].size();
for(int k=n; k--;)
run[i][j][k]=A[j][k];
}
for(int i=n; i--;){
solved[i][i]=i;
solve(i, i);
}
for(int i=n; i--;)for(int j: adjLis[i]){
solved[i][j]=j;
solve(i, j);
}
if(*min_element(solved[0].begin(), solved[0].end())>=0)
return cop=0;
return -1;
}
int nextMove(int r){
return cop=solved[cop][r];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
441 ms |
19844 KB |
Output is correct |
5 |
Correct |
58 ms |
5000 KB |
Output is correct |
6 |
Correct |
460 ms |
19520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
437 ms |
19208 KB |
Output is correct |
4 |
Correct |
428 ms |
19736 KB |
Output is correct |
5 |
Correct |
406 ms |
18496 KB |
Output is correct |
6 |
Correct |
443 ms |
19440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
5 ms |
1100 KB |
Output is correct |
11 |
Correct |
9 ms |
1096 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
3 ms |
712 KB |
Output is correct |
14 |
Correct |
6 ms |
1096 KB |
Output is correct |
15 |
Correct |
2 ms |
584 KB |
Output is correct |
16 |
Correct |
3 ms |
584 KB |
Output is correct |
17 |
Correct |
13 ms |
1352 KB |
Output is correct |
18 |
Correct |
5 ms |
1096 KB |
Output is correct |
19 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
441 ms |
19844 KB |
Output is correct |
5 |
Correct |
58 ms |
5000 KB |
Output is correct |
6 |
Correct |
460 ms |
19520 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
437 ms |
19208 KB |
Output is correct |
10 |
Correct |
428 ms |
19736 KB |
Output is correct |
11 |
Correct |
406 ms |
18496 KB |
Output is correct |
12 |
Correct |
443 ms |
19440 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
0 ms |
200 KB |
Output is correct |
17 |
Correct |
1 ms |
328 KB |
Output is correct |
18 |
Correct |
1 ms |
200 KB |
Output is correct |
19 |
Correct |
1 ms |
200 KB |
Output is correct |
20 |
Correct |
1 ms |
328 KB |
Output is correct |
21 |
Correct |
1 ms |
328 KB |
Output is correct |
22 |
Correct |
5 ms |
1100 KB |
Output is correct |
23 |
Correct |
9 ms |
1096 KB |
Output is correct |
24 |
Correct |
1 ms |
328 KB |
Output is correct |
25 |
Correct |
3 ms |
712 KB |
Output is correct |
26 |
Correct |
6 ms |
1096 KB |
Output is correct |
27 |
Correct |
2 ms |
584 KB |
Output is correct |
28 |
Correct |
3 ms |
584 KB |
Output is correct |
29 |
Correct |
13 ms |
1352 KB |
Output is correct |
30 |
Correct |
5 ms |
1096 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |
33 |
Correct |
0 ms |
200 KB |
Output is correct |
34 |
Correct |
1 ms |
328 KB |
Output is correct |
35 |
Correct |
437 ms |
19844 KB |
Output is correct |
36 |
Correct |
61 ms |
5064 KB |
Output is correct |
37 |
Correct |
453 ms |
19488 KB |
Output is correct |
38 |
Correct |
1 ms |
200 KB |
Output is correct |
39 |
Correct |
1 ms |
332 KB |
Output is correct |
40 |
Correct |
429 ms |
19220 KB |
Output is correct |
41 |
Correct |
431 ms |
19852 KB |
Output is correct |
42 |
Correct |
411 ms |
18448 KB |
Output is correct |
43 |
Correct |
431 ms |
19508 KB |
Output is correct |
44 |
Correct |
0 ms |
200 KB |
Output is correct |
45 |
Correct |
1 ms |
200 KB |
Output is correct |
46 |
Correct |
1 ms |
328 KB |
Output is correct |
47 |
Correct |
1 ms |
328 KB |
Output is correct |
48 |
Correct |
5 ms |
1096 KB |
Output is correct |
49 |
Correct |
8 ms |
1096 KB |
Output is correct |
50 |
Correct |
1 ms |
328 KB |
Output is correct |
51 |
Correct |
3 ms |
712 KB |
Output is correct |
52 |
Correct |
6 ms |
1096 KB |
Output is correct |
53 |
Correct |
2 ms |
584 KB |
Output is correct |
54 |
Correct |
2 ms |
584 KB |
Output is correct |
55 |
Correct |
13 ms |
1352 KB |
Output is correct |
56 |
Correct |
5 ms |
1096 KB |
Output is correct |
57 |
Correct |
30 ms |
3336 KB |
Output is correct |
58 |
Correct |
210 ms |
11968 KB |
Output is correct |
59 |
Correct |
394 ms |
18508 KB |
Output is correct |
60 |
Execution timed out |
3062 ms |
20544 KB |
Time limit exceeded |
61 |
Halted |
0 ms |
0 KB |
- |