#include "coprobber.h"
#include<bits/stdc++.h>
using namespace std;
int win[MAX_N][MAX_N][2];
int go[MAX_N][MAX_N];
int cop;
int start(int N, bool A[MAX_N][MAX_N])
{
memset(win, 0, sizeof(win));
memset(go, 0, sizeof(go));
for (int timer = 0; timer < N; timer++){
for (int i = 0; i < N; i++){
for (int j = 0; j < N; j++){
//ako sme na ista pozicija, pobeda
if (i == j){
win[i][j][0] = 1;
win[i][j][1] = 1;
go[i][j] = i;
continue;
}
//nie sme na poteg
bool forced_pobeda = 0;
for (int k = 0; k < N; k++){
if (A[i][k]){
if (win[k][j][1]) go[i][j] = k;
forced_pobeda |= win[k][j][1];
}
}
win[i][j][0] = forced_pobeda;
//toj e na poteg
forced_pobeda = 1;
for (int k = 0; k < N; k++){
if (A[j][k]){
forced_pobeda &= win[i][k][0];
}
}
win[i][j][1] = forced_pobeda;
}
}
}
for (int starting = 0; starting < N; starting++){
bool forced = 1;
for (int j = 0; j < N; j++){
forced &= win[starting][j][0];
}
if (forced){
cop = starting;
return starting;
}
}
return -1;
}
int nextMove(int R)
{
cop = go[cop][R];
return cop;;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3152 KB |
Output is correct |
2 |
Correct |
1 ms |
3152 KB |
Output is correct |
3 |
Correct |
1 ms |
3152 KB |
Output is correct |
4 |
Execution timed out |
3041 ms |
4416 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
3152 KB |
Cop can catch the robber, but start() returned -1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3152 KB |
Output is correct |
2 |
Correct |
1 ms |
3152 KB |
Output is correct |
3 |
Correct |
1 ms |
3152 KB |
Output is correct |
4 |
Incorrect |
1 ms |
3152 KB |
Cop can catch the robber, but start() returned -1 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3152 KB |
Output is correct |
2 |
Correct |
1 ms |
3152 KB |
Output is correct |
3 |
Correct |
1 ms |
3152 KB |
Output is correct |
4 |
Execution timed out |
3041 ms |
4416 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |