This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 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;;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |