Submission #302392

#TimeUsernameProblemLanguageResultExecution timeMemory
302392dantoh000Cop and Robber (BOI14_coprobber)C++14
100 / 100
1378 ms8104 KiB
#include <bits/stdc++.h> #include "coprobber.h" using namespace std; typedef tuple<int,int,int> iii; bool state[505][505][2]; int num[505][505]; int ct[505]; int G[505][505]; int pa[505][505]; int st = -1; queue<iii> Q; int start(int N, bool A[MAX_N][MAX_N]) { for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ G[i][j] = A[i][j]; ct[i] += G[i][j]; } state[i][i][0] = state[i][i][1] = 1; pa[i][i] = -1; Q.emplace(i,i,0); Q.emplace(i,i,1); } while (Q.size()){ int x, y, flag; tie(x,y,flag) = Q.front(); Q.pop(); if (flag){ for (int i = 0; i < N; i++){ if (G[x][i] || i==x){ if (state[i][y][0]) continue; pa[i][y] = x; state[i][y][0] = true; Q.emplace(i,y,0); } } } else{ for (int i = 0; i < N; i++){ if (G[i][y]){ num[x][i]++; if (num[x][i] == ct[i]){ state[x][i][1] = true; Q.emplace(x,i,1); } } } } } for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ if (state[i][j][0] == false) break; if (j == N-1) st = i; } } return st; } int nextMove(int R) { return st = pa[st][R]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...