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<vector>
#define NN 500
#pragma GCC optimize(2)
int ok[NN][NN][2], nxt[NN][NN], vis[NN][NN][2], sz[NN][NN];
bool a[NN][NN];
std::vector<int> adj[NN];
int pos;
void dfs(int x, int y, int who)
{
ok[x][y][who] = 1;
if (who == 1) {
for (auto i : adj[x])
if (!ok[i][y][0])
nxt[i][y] = x,dfs(i, y, 0);
if (!ok[x][y][0])
nxt[x][y] = x,dfs(x, y, 0);
} else
for (auto i : adj[y])
if (!--sz[x][i] && !ok[x][i][1])
dfs(x, i, 1);
}
int start(int N, bool A[NN][NN])
{
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
if (A[i][j])
adj[i].push_back(j);
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
sz[i][j] = adj[j].size();
for (int i = 0; i < N; i++) {
if (!ok[i][i][0])
dfs(i, i , 0);
if (!ok[i][i][1])
dfs(i, i, 1);
}
for (pos = 0; pos < N; pos++) {
bool still = 1;
for (int i = 0; i < N; i++)
if (!ok[pos][i][0])
still = 0;
if (still)
return pos;
}
return -1;
}
int nextMove(int R) {
return pos=nxt[pos][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... |