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 <bits/stdc++.h>
using namespace std;
#define MAX_N 500
// modify the following functions
// you can define global variables and functions
int n, dist[MAX_N][MAX_N];
bool edge[MAX_N][MAX_N];
void dfs(int v, int s, int p = -1){
for (int u = 0; u < n; u ++)
if (u != p and edge[v][u]){
dist[s][u] = dist[s][v] + 1;
dfs(u, s, v);
}
}
int start(int N, bool A[MAX_N][MAX_N]) {
n = N;
for (int i = 0; i < n; i ++)
for (int j = 0; j < n; j ++)
edge[i][j] = A[i][j];
for (int i = 0; i < n; i ++)
dfs(i, i);
return 0;
}
int cur = 0;
int nextMove(int R) {
if (dist[cur][R] == 1)
return cur;
for (int i = 0; i < n; i ++){
if (edge[cur][i] and dist[i][R] < dist[cur][R])
return i;
}
return cur;
}
# | 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... |