이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "coprobber.h"
using namespace std;
vector<vector<int>> AR;
int cop[500][500], robber[500][500];
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);
}
}
}
int choixrobber[500][500];
for (int i = 0; i < N; i++)
for (int j = 0; j < 500; j++)
{
robber[i][j] = -1;
cop[i][j] = -1;
}
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++)
{
if (cop[AR[temp[0]][i]][temp[1]] == -1)
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);
}*/
컴파일 시 표준 에러 (stderr) 메시지
coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:49:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int i = 0; i < AR[temp[1]].size(); i++)
| ~~^~~~~~~~~~~~~~~~~~~~
coprobber.cpp:63:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for (int i = 0; i < AR[temp[0]].size(); i++)
| ~~^~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |