제출 #476541

#제출 시각아이디문제언어결과실행 시간메모리
476541SamAnd경찰관과 강도 (BOI14_coprobber)C++17
60 / 100
1301 ms262148 KiB
#include "coprobber.h" #include <iostream> #include <set> #include <cstring> #include <cassert> #include <vector> #include <queue> using namespace std; #define m_p make_pair #define fi first #define se second const int N = 503; int n; bool a[N][N]; int cnt[N][N][2]; vector<pair<pair<int, int>, bool> > rg[N][N][2]; void ave(pair<pair<int, int>, bool> x, pair<pair<int, int>, bool> y) { rg[y.fi.fi][y.fi.se][y.se].push_back(x); ++cnt[x.fi.fi][x.fi.se][x.se]; } bool c[N][N][2]; int p[N][N]; int u; int start(int NN, bool A[MAX_N][MAX_N]) { n = NN; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { a[i][j] = A[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { ave(m_p(m_p(i, j), 1), m_p(m_p(i, j), 0)); for (int k = 0; k < n; ++k) { if (a[i][k]) { ave(m_p(m_p(i, j), 1), m_p(m_p(k, j), 0)); } if (a[j][k]) { ave(m_p(m_p(i, j), 0), m_p(m_p(i, k), 1)); } } } } queue<pair<pair<int, int>, bool> > q; for (int i = 0; i < n; ++i) { c[i][i][0] = true; q.push(m_p(m_p(i, i), 0)); c[i][i][1] = true; q.push(m_p(m_p(i, i), 1)); } while (!q.empty()) { int u = q.front().fi.fi; int r = q.front().fi.se; bool z = q.front().se; q.pop(); for (int i = 0; i < rg[u][r][z].size(); ++i) { pair<pair<int, int>, bool> h = rg[u][r][z][i]; if (h.se) { if (!c[h.fi.fi][h.fi.se][h.se]) { p[h.fi.fi][h.fi.se] = u; c[h.fi.fi][h.fi.se][h.se] = true; q.push(h); } } else { --cnt[h.fi.fi][h.fi.se][h.se]; if (cnt[h.fi.fi][h.fi.se][h.se] == 0 && !c[h.fi.fi][h.fi.se][h.se]) { c[h.fi.fi][h.fi.se][h.se] = true; q.push(h); } } } } for (u = 0; u < n; ++u) { bool z = true; for (int r = 0; r < n; ++r) { if (!c[u][r][1]) { z = false; break; } } if (z) { return u; } } return -1; } int nextMove(int r) { assert(c[u][r][1]); return (u = p[u][r]); }

컴파일 시 표준 에러 (stderr) 메시지

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:79:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         for (int i = 0; i < rg[u][r][z].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...