# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1075965 | raphaelp | Cop and Robber (BOI14_coprobber) | C++14 | 0 ms | 0 KiB |
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;
vector<vector<int>> AR;
int pos = 0;
int start(int N, int A[500][500])
{
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if (A[i][j])
{
AR[i].push_back(j);
AR[j].push_back(i);
}
}
}
for (int i = 0; i < N; i++)
{
vector<int> occ(N);
queue<int> Q;
occ[i] = 2;
for (int j = 0; j < AR[i].size(); j++)
{
int x = AR[i][j];
occ[x] = x;
for (int k = 0; k < AR[x].size(); k++)
{
if (occ[AR[x][k]])
occ[AR[x][k]] = -1;
else
occ[AR[x][k]] = x;
}
}
for (int j = 0; j < N; j++)
if (occ[j] != j && occ[j] != 0 && occ[j] != -1)
Q.push(j);
while (!Q.empty())
{
int x = Q.front();
Q.pop();
for (int j = 0; j < AR[x].size(); j++)
{
if (occ[AR[x][j]] != 0 && occ[AR[x][j]] != occ[x])
return -1;
occ[AR[x][j]] = occ[x];
Q.push(AR[x][j]);
}
}
}
return 1;
}
int nextMove(int R)
{
return -1;
}