이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "coprobber.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define N 1000003
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;
int d[500][500][2], dg[500][500][2], m, n;
int mv[500][500][2], gl, sm[500];
bool a[500][500];
bool is_n (int x, int y, int t, int i) {
if (t) return a[x][i] || (x == i);
return a[y][i];
}
int start (int v, bool A[][500]) {
n = v;
m = 2 * n * n;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
sm[i] += (int) A[i][j];
memcpy (a, A, sizeof (a));
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) {
dg[i][j][0] = sm[i] + 1;
dg[i][j][1] = sm[j];
d[i][j][0] = d[i][j][1] = 2;
}
queue <tuple <int, int, int>> q;
for (int i = 0; i < n; i++) {
d[i][i][0] = 1, d[i][i][1] = 0;
q.push ({i, i, 0}), q.push ({i, i, 1});
}
while (!q.empty ()) {
auto s = q.front ();
int x, y, t;
tie (x, y, t) = s;
q.pop ();
for (int i = 0; i < n; i++) {
if (is_n (x, y, t, i)) {
int a = x, b = y, c = !t;
if (t) a = i; else b = i;
if (d[a][b][c] != 2) continue;
if (!d[x][y][t]) {
d[a][b][c] = 1, mv[a][b][c] = x;
} else {
if (--dg[a][b][c] < 1) {
d[a][b][c] = 0;
q.push ({a, b, c});
}
}
}
}
}
for (int i = 0; i < n; i++) {
int ok = 1;
for (int j = 0; j < n; j++) {
if (d[i][j][0] != 1) {
ok = 0; break;
}
}
if (ok) return gl = i;
}
return -1;
}
int nextMove (int x) {
return gl = mv[gl][x][0];
}
# | 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... |