Submission #1076272

#TimeUsernameProblemLanguageResultExecution timeMemory
1076272raphaelpCop and Robber (BOI14_coprobber)C++14
60 / 100
732 ms262144 KiB
#include <bits/stdc++.h> #include "coprobber.h" using namespace std; vector<vector<int>> AR; vector<vector<int>> cop, robber; int pos = 0; int start(int N, bool A[500][500]) { AR.assign(N, {}); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (A[i][j]) { AR[j].push_back(i); } } } cop.assign(500, vector<int>(500, -1)), robber.assign(500, vector<int>(500, -1)); vector<vector<int>> choixcop(500, vector<int>(500)), choixrobber(500, vector<int>(500)); queue<vector<int>> Q; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { choixrobber[i][j] = AR[j].size(); } } for (int i = 0; i < N; i++) { Q.push({i, i, 0, 0}); Q.push({i, i, 1}); } while (!Q.empty()) { vector<int> temp = Q.front(); Q.pop(); if (temp[2] == 0) { if (cop[temp[0]][temp[1]] != -1) continue; cop[temp[0]][temp[1]] = temp[3]; for (int i = 0; i < AR[temp[1]].size(); i++) { choixrobber[temp[0]][AR[temp[1]][i]]--; if (choixrobber[temp[0]][AR[temp[1]][i]] == 0) Q.push({temp[0], AR[temp[1]][i], 1}); } } else { if (robber[temp[0]][temp[1]] != -1) continue; choixrobber[temp[0]][temp[1]] = 0; robber[temp[0]][temp[1]] = 1; Q.push({temp[0], temp[1], 0, temp[0]}); for (int i = 0; i < AR[temp[0]].size(); i++) { Q.push({AR[temp[0]][i], temp[1], 0, temp[0]}); } } } int x = -1; bool b = 1; while (b) { x++; if (x == N) return -1; b = 0; for (int i = 0; i < N; i++) if (cop[x][i] == -1) b = 1; } pos = x; return x; } int nextMove(int R) { pos = cop[pos][R]; return pos; } /*int main() { int N = 500; vector<vector<int>> A = {{0, 1, 1, 0}, {1, 0, 0, 1}, {1, 0, 0, 1}, {0, 1, 1, 0}}; cout << start(N, A); }*/

Compilation message (stderr)

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:44:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for (int i = 0; i < AR[temp[1]].size(); i++)
      |                             ~~^~~~~~~~~~~~~~~~~~~~
coprobber.cpp:58:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             for (int i = 0; i < AR[temp[0]].size(); i++)
      |                             ~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...