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 <bits/stdc++.h>
#include "coprobber.h"
using namespace std;
typedef tuple<int,int,int> iii;
bool state[505][505][2];
int num[505][505];
int ct[505];
int G[505][505];
int pa[505][505];
int st = -1;
queue<iii> Q;
int start(int N, bool A[MAX_N][MAX_N])
{
for (int i = 0; i < N; i++){
for (int j = 0; j < N; j++){
G[i][j] = A[i][j];
ct[i] += G[i][j];
}
state[i][i][0] = state[i][i][1] = 1;
pa[i][i] = -1;
Q.emplace(i,i,0);
Q.emplace(i,i,1);
}
while (Q.size()){
int x, y, flag;
tie(x,y,flag) = Q.front(); Q.pop();
if (flag){
for (int i = 0; i < N; i++){
if (G[x][i] || i==x){
if (state[i][y][0]) continue;
pa[i][y] = x;
state[i][y][0] = true;
Q.emplace(i,y,0);
}
}
}
else{
for (int i = 0; i < N; i++){
if (G[i][y]){
num[x][i]++;
if (num[x][i] == ct[i]){
state[x][i][1] = true;
Q.emplace(x,i,1);
}
}
}
}
}
for (int i = 0; i < N; i++){
for (int j = 0; j < N; j++){
if (state[i][j][0] == false) break;
if (j == N-1) st = i;
}
}
return st;
}
int nextMove(int R)
{
return st = pa[st][R];
}
# | 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... |