# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234667 | BamiTorabi | 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.
//Sasayego! Sasayego! Shinzou wo Sasageyo!
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#include "coprobber.h"
#define debug(x) cerr << #x << " = " << x << endl
#define lid (id << 1)
#define rid (lid ^ 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
int arumin[MAX_N][MAX_N][2], eren[MAX_N][MAX_N];
int annie[MAX_N][MAX_N], deg[MAX_N], shingeki;
queue <int> 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++)
if (A[i][j])
deg[i]++;
for (int j = 0; j < n; j++)
annie[j][i] = deg[i];
}
for (int i = 0; i < n; i++)
for (int b = 0; b < 2; b++){
arumin[i][i][b] = 1;
eren[i][i] = i;
Q.push(b * n * n + i * n + j);
}
while (!Q.empty()){
int x = Q.front();;
Q.pop();
bool b = (x >= n * n);
x -= b * n * n;
int att = x / n;
int fem = x % n;
if (b)
for (int u = 0; u < n; u++)
if (A[u][fem]){
annie[att][u]--;
if (annie[att][u] == 0 && !arumin[att][u][0]){
arumin[att][u][0] = 1;
Q.push(n * att + u);
}
}
else
for (int u = 0; u < n; u++)
if ((A[u][att] || u == att) && !arumin[u][fem][1]){
arumin[u][fem][1] = 1;
eren[u][fem] = att;
Q.push(n * n + u * n + fem);
}
}
shingeki = -1;
for (int i = 0; i < n; i++){
bool flag = true;
for (int j = 0; j < n; j++)
flag &= (arumin[i][j][1]);
if (flag)
shingeki = i;
}
return shingeki;
}
int nextMove(int femaleTitan){
return shingeki = eren[shingeki][femaleTitan];
}