Submission #656286

#TimeUsernameProblemLanguageResultExecution timeMemory
656286600MihneaCop and Robber (BOI14_coprobber)C++17
0 / 100
1 ms2256 KiB
#include "coprobber.h" #include <bits/stdc++.h> using namespace std; const int N = 500 + 7; int n; vector<int> g[N]; int wn[N][N][2]; enum {COP, ROB}; /** win[cop][rob][move] = if the cop can win if cop == rob: win[cop][rob][move] = 1 if move == C: if at least one from {win[cop'][rob][R] == 1}: win[cop][rob][C] = 1 if move == R: if all moves {win[cop][rob'][C] == 1}: win[cop][rob][R] = 1 **/ int cnt_good; int cnt_bad; int cnt_unsure; void add(int x) { assert(x == -1 || x == 0 || x == +1); if (x == -1) cnt_unsure++; if (x == 0) cnt_bad++; if (x == 1) cnt_good++; } int start(int nn, bool AE[MAX_N][MAX_N]) { n = nn; for (int i = 0; i < n; i++) { assert(g[i].empty()); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (AE[i][j]) { assert(AE[j][i]); assert(i != j); g[i].push_back(j); } } assert(AE[i][i] == 0); } if (0) { cout << "graph = \n"; for (int i = 0; i < n; i++) { for (auto &j : g[i]) { cout << "\t\t\t\t\t" << i << " --> " << j << "\n"; } } } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { wn[i][j][COP] = wn[i][j][ROB] = -1; /// unsure } } for (int i = 0; i < n; i++) { wn[i][i][COP] = wn[i][i][ROB] = 1; } while (1) { bool change = 0; for (int cop = 0; cop < n; cop++) { for (int rob = 0; rob < n; rob++) { if (wn[cop][rob][COP] == -1) { /// if it is unsure cnt_good = cnt_bad = cnt_unsure = 0; add(wn[cop][rob][ROB]); for (auto &vecin : g[cop]) { add(wn[vecin][rob][ROB]); } if (cnt_good >= 1) { change = 1; wn[cop][rob][COP] = 1; } assert(cnt_unsure >= 1); } if (wn[rob][cop][ROB] == -1) { /// if it is unsure cnt_good = cnt_bad = cnt_unsure = 0; for (auto &vecin : g[rob]) { add(wn[cop][vecin][COP]); } if (cnt_unsure == 0 && cnt_good == 0) { change = 1; wn[cop][rob][ROB] = 1; } if (cnt_bad >= 1) { change = 1; wn[cop][rob][ROB] = 0; } } } } if (!change) { break; } } for (int cop = 0; cop < n; cop++) { bool good = 1; for (int rob = 0; rob < n; rob++) { good &= (wn[cop][rob][COP] == 1); } if (good) { return cop; } } return -1; } int nextMove(int R) { return -1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...