Submission #107627

#TimeUsernameProblemLanguageResultExecution timeMemory
107627patrikpavic2Cop and Robber (BOI14_coprobber)C++17
30 / 100
161 ms3064 KiB
#include "coprobber.h" #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <set> #include <cstdlib> #include <vector> #include <map> using namespace std; const int INF = 0x3f3f3f3f; int mv = 0, pos, n, m, E, V; bool a[MAX_N][MAX_N]; int dis[MAX_N][MAX_N]; vector < int > v[MAX_N]; int start(int N, bool A[MAX_N][MAX_N]){ for(int i = 0;i < MAX_N;i++){ for(int j = 0;j < MAX_N;j++){ a[i][j] = A[i][j]; E += A[i][j]; dis[i][j] = INF * (1 - a[i][j]) + 1; if(a[i][j]) v[i].push_back(j); } dis[i][i] = 0; } V = N; for(int k = 0;k < N;k++){ for(int i = 0;i < N;i++){ for(int j = 0;j < N;j++){ dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); } } } E /= 2; if(E == V - 1) return pos = 0; while(A[m][m + 1]) m++;m++; n = N / m; return pos = (n / 2) * m + m / 2; } int nextMove(int R){ if(a[R][pos]) return R; if(E == V - 1){ if(dis[pos][R] % 2 == 0) return pos; for(int x : v[pos]){ if(dis[x][R] < dis[pos][R]) return pos = x; } } int Px = pos / m, Py = pos % m; int Rx = R / m, Ry = R % m; if((Px + Py) % 2 == (Rx + Ry) % 2) return pos; if(abs(Px - Rx) < 2) { if(Py < Ry) return pos = pos + 1; return pos = pos - 1; } if(Px < Rx) return pos = pos + m; return pos = pos - m; }

Compilation message (stderr)

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:39:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
     while(A[m][m + 1]) m++;m++;
     ^~~~~
coprobber.cpp:39:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
     while(A[m][m + 1]) m++;m++;
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...