This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// IOI 2021
#include <bits/stdc++.h>
#include "coprobber.h"
using namespace std;
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
////////////////////////////////////////////////////////////////////
const int N = MAX_N;
queue< pair<bool, pii> > Q;
bool W[2][N][N];
int C, D[N], S[N][N], P[N][N];
int start(int n, bool A[N][N]) {
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) D[i] += (A[i][j]);
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) S[i][j] = D[j];
for (int i = 0; i < n; i++) for (int t = 0; t < 2; t++) Q.push(make_pair(t, make_pair(i, i))), W[t][i][i] = 1, P[i][i] = i;
while (!Q.empty()) {
pair<bool, pii> state = Q.front(); Q.pop();
int t = state.first, c = state.second.first, r = state.second.second;
if (t) {
for(int rr = 0; rr < n; rr++) if (A[r][rr] && --S[c][rr] == 0 && !W[0][c][rr])
W[0][c][rr] = 1, Q.push(make_pair(0, make_pair(c, rr)));
} else {
for (int cc = 0; cc < n; cc++) if ((c == cc || A[c][cc]) && !W[1][cc][r])
W[1][cc][r] = 1, P[cc][r] = c, Q.push(make_pair(1, make_pair(cc, r)));
}
}
for (int i = 0; i < n; i++) {
bool f = 1;
for (int j = 0; j < n; j++) f &= W[1][i][j];
if (f) return C = i;
}
return -1;
}
int nextMove(int R) {
return C = P[C][R];
}
/*
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
mt19937 Rnd(time(0));
return 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... |