이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |