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 <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define rank rank228
#define y1 y1228
#define pb push_back
#define mp make_pair
using ll = long long;
using ld = long double;
bool win[MAX_N][MAX_N][2];
int moves[MAX_N][MAX_N][2];
int cnt[MAX_N][MAX_N][2];
int deg[MAX_N];
int pos;
int start(int n, bool A[MAX_N][MAX_N]) {
queue<pair<pair<int, int>, int> > q;
for (int i = 0; i < n; i++) {
for (int t = 0; t < 2; t++) {
win[i][i][t] = true;
q.push(mp(mp(i, i), t));
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (A[i][j] && j != i) {
deg[i]++;
}
}
}
while (!q.empty()) {
auto x = q.front();
q.pop();
int t = x.second;
int i = x.first.first;
int j = x.first.second;
if (t == 1) {
for (int k = 0; k < n; k++) {
if ((i == k || A[k][i]) && !win[k][j][t ^ 1]) {
win[k][j][t ^ 1] = true;
moves[k][j][t ^ 1] = i;
q.push(mp(mp(k, j), t ^ 1));
}
}
} else {
for (int k = 0; k < n; k++) {
if (A[k][j] && !win[i][k][t ^ 1]) {
cnt[i][k][t ^ 1]++;
if (cnt[i][k][t ^ 1] == deg[k]) {
win[i][k][t ^ 1] = true;
q.push(mp(mp(i, k), t ^ 1));
}
}
}
}
}
pos = -1;
for (int i = 0; i < n; i++) {
bool bad = false;
for (int j = 0; j < n; j++) {
if (!win[i][j][0]) {
bad = true;
}
}
if (!bad) {
pos = i;
}
}
return pos;
}
int nextMove(int R) {
pos = moves[pos][R][0];
return pos;
}
# | 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... |