이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
# include "coprobber.h"
int pos;
int val[505][505][2];
int vis[505][505][2];
int b[505][505], c[505][505];
int start(int n, bool a[MAX_N][MAX_N]) {
vector<int> g[n+1];
for(int i=0; i<n; i++){
for(int l=0; l<n; l++){
b[i][l]=-1;
if(a[i][l]){
g[i].push_back(l);
}
}
}
vector<array<int, 3>> q;
for(int i=0; i<n; i++){
val[i][i][0]=1;
val[i][i][1]=0;
b[i][i]=i;
q.push_back({i, i, 1});
q.push_back({i, i, 0});
}
while(pos<q.size()){
auto [x, y, z]=q[pos];
if(vis[x][y][z]){
pos++;
}
else{
// cout<<val[x][y][z]<<"\n";
vis[x][y][z]=1;
if(z==0){
val[x][y][z]=1;
for(auto i: g[y]){
if(vis[x][i][1]) continue;
c[x][i]++;
if(c[x][i]==g[i].size()){
val[x][i][1]=0;
q.push_back({x, i, 1});
}
}
}
else {
val[x][y][z] = 0;
for(auto i: g[x]){
if(vis[i][y][0]) continue;
if(b[i][y]==-1)
b[i][y]=x;
q.push_back({i, y, 0});
}
if(b[x][y]==-1)
b[x][y]=x;
if(!vis[x][y][0])
q.push_back({x, y, 0});
}
pos++;
}
}
for(int i=0; i<n; i++){
int flag=1;
for(int j=0; j<n; j++){
if(val[i][j][0]==0){
flag=0;
}
}
if(flag){
return pos=i;
}
}
return -1;
}
int nextMove(int R) {
return pos=b[pos][R];
}
컴파일 시 표준 에러 (stderr) 메시지
coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:33:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | while(pos<q.size()){
| ~~~^~~~~~~~~
coprobber.cpp:46:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | if(c[x][i]==g[i].size()){
| ~~~~~~~^~~~~~~~~~~~~
# | 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... |