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 "bits/stdc++.h"
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif
#define ar array
const int M = 505;
int dp[2][M][M], par[M][M];
int d[M][M], s;
int start(int n, bool a[MAX_N][MAX_N]){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k=0;k<n;k++){
d[j][i] += a[j][k];
}
}
}
queue<ar<int, 3>> q;
for(int i=0;i<n;i++){
dp[0][i][i] = 1, dp[1][i][i] = 1;
q.push({0, i, i});
q.push({1, i, i});
}
while(!q.empty()){
auto [t, u, v] = q.front(); q.pop();
for(int i=0;i<n;i++){
if(t){
if(a[i][u]) d[i][v]--;
if(a[i][u] && !d[i][v] && !dp[0][i][v]){
dp[0][i][v] = 1;
q.push({0, i, v});
}
} else {
if(a[i][v] && !dp[1][u][i]){
par[u][i] = v;
dp[1][u][i] = 1;
q.push({1, u, i});
}
}
}
}
s = -1;
for(int i=0;i<n;i++){
bool ok = 1;
for(int j=0;j<n;j++){
if(!dp[1][j][i]) ok = 0;
}
if(ok){
s = i;
break;
}
}
return s;
}
int nextMove(int R){
s = par[R][s];
return s;
}
# | 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... |