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;
int n, C = 0;
vector<vector<int>> dist;
int start(int N, bool A[MAX_N][MAX_N]) {
n = N;
dist.resize(n, vector<int>(n, 0));
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++)
if (A[i][j])
dist[i][j] = dist[j][i] = 1;
else
dist[i][j] = dist[j][i] = 1e9;
}
for (int k = 0; k < n; k++) {
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
return C;
}
int nextMove(int R) {
int prev_C = C;
int closest = 1e9;
for (int i = 0; i < n; i++) {
if (dist[prev_C][i] == 1 && dist[R][i] <= closest)
closest = dist[R][i], C = i;
}
return C;
}
# | 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... |