이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "coprobber.h"
using namespace std;
struct Po {
int c, r, t;
};
Po getPo(int i, int j, int k) {
Po ans;
ans.c = i;
ans.r = j;
ans.t = k;
return ans;
}
bool adj[MAX_N][MAX_N];
bool dp[MAX_N][MAX_N][2];
bool vis[MAX_N][MAX_N][2];
int rem[MAX_N][MAX_N][2];
// rem[i][j][0] = how many do I need to remove from position (i, j) to be able to add it
// (i, j, 0) needs to have all zeroes
// (i, j, 1) needs to have all ones
int n;
int atual;
int start(int N, bool A[MAX_N][MAX_N]) {
#pragma region Set values
n = N;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
adj[i][j] = A[i][j];
for (int k = 0; k < n; k++) {
rem[k][i][1]++;
rem[i][k][0];
}
}
}
#pragma endregion
queue<Po> process;
for (int i = 0; i < n; i++) {
dp[i][i][0] = dp[i][i][1] = 1;
vis[i][i][0] = vis[i][i][1] = 1;
process.push(getPo(i, i, 0));
process.push(getPo(i, i, 1));
}
while (!process.empty()) {
auto u = process.front();
process.pop();
if (u.t) {
// robbers turn
for (int i = 0; i < n; i++) {
if (!adj[u.c][i] || vis[i][u.r][0]) continue;
if (dp[u.c][u.r][1]) {
rem[i][u.r][0]--;
if (rem[i][u.r][0] == 0) {
dp[i][u.r][0] = 0;
vis[i][u.r][0] = 1;
process.push(getPo(i, u.r, 0));
}
} else {
dp[i][u.r][0] = 1;
vis[i][u.r][0] = 1;
process.push(getPo(i, u.r, 0));
}
}
} else {
// cops turn
for (int i = 0; i < n; i++) {
if (!adj[u.r][i] || vis[u.c][i][1]) continue;
if (dp[u.c][u.r][0]) {
rem[u.c][i][1]--;
if (rem[u.c][i][1] == 0) {
dp[u.c][i][1] = 1;
vis[u.c][i][1] = 1;
process.push(getPo(u.c, i, 1));
}
} else {
dp[u.c][i][1] = 0;
vis[u.c][i][1] = 1;
process.push(getPo(u.c, i, 1));
}
}
}
}
for (int i = 0; i < n; i++) {
bool ok = 1;
for (int j = 0; j < n; j++) ok = (ok && dp[i][j][0]);
if (ok) {
return (atual = i);
}
}
return -1;
}
int nextMove(int R) {
for (int i = 0; i < n; i++) {
if (!adj[atual][i]) continue;
if (dp[i][R][0]) return (atual = i);
}
}
컴파일 시 표준 에러 (stderr) 메시지
coprobber.cpp:29: warning: ignoring '#pragma region Set' [-Wunknown-pragmas]
29 | #pragma region Set values
|
coprobber.cpp:40: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
40 | #pragma endregion
|
coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:36:28: warning: statement has no effect [-Wunused-value]
36 | rem[i][k][0];
| ~~~~~~~~~~~^
coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:102:1: warning: control reaches end of non-void function [-Wreturn-type]
102 | }
| ^
# | 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... |