Submission #955511

#TimeUsernameProblemLanguageResultExecution timeMemory
955511mdbrnowskiCop and Robber (BOI14_coprobber)C++17
0 / 100
1 ms344 KiB
#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.assign(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; } 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[C][i] == 1 && dist[R][i] < closest) closest = dist[R][i], C = i; } if (closest == 1) return prev_C; return C; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...