Submission #97946

#TimeUsernameProblemLanguageResultExecution timeMemory
97946SpeedOfMagicCop and Robber (BOI14_coprobber)C++17
60 / 100
1583 ms226952 KiB
#include "coprobber.h" #include <bits/stdc++.h> using namespace std; const int maxN = 500; const int M = 2 * maxN * maxN; vector<int> g[maxN]; vector<int> g2[M], rev2[M]; //0 if it's officer's turn, 1 if robber's one int enc(int officerPos, int robberPos, int whoseTurn) { return whoseTurn * maxN * maxN + officerPos * maxN + robberPos; } char vis[M]; int good[M]; int d[M]; void expand(int cur) { if (cur / (maxN * maxN) && d[cur] == g2[cur].size()) good[cur] = g2[cur].empty() ? -2 : g2[cur][0]; else if (cur / (maxN * maxN) == 0 && (d[cur] || g2[cur].size() == 0)) { good[cur] = -2; for (int i : g2[cur]) if (good[i] != -1) { good[cur] = i; break; } } if (good[cur] != -1) for (int i : rev2[cur]) if (good[i] == -1) { d[i]++; expand(i); } } void add(int v, int u) { g2[v].push_back(u); rev2[u].push_back(v); } int loc; int start(int N, bool A[MAX_N][MAX_N]) { memset(good, -1, sizeof good); memset(d, 0, sizeof d); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (A[i][j]) g[i].push_back(j); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (i != j) { add(enc(i, j, 0), enc(i, j, 1)); for (int k : g[i]) add(enc(i, j, 0), enc(k, j, 1)); for (int k : g[j]) add(enc(i, j, 1), enc(i, k, 0)); } for (int i = 0; i < N; i++) { expand(enc(i, i, 0)); expand(enc(i, i, 1)); } for (int i = 0; i < N; i++) { bool no = 0; for (int j = 0; j < N; j++) no |= good[enc(i, j, 0)] == -1; if (!no) { loc = i; return i; } } return -1; } int nextMove(int R) { //cout << loc << " " << R << endl; loc = good[enc(loc, R, 0)] % (maxN * maxN) / maxN; return loc; }

Compilation message (stderr)

coprobber.cpp: In function 'void expand(int)':
coprobber.cpp:20:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (cur / (maxN * maxN) && d[cur] == g2[cur].size()) 
                             ~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...