이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include "coprobber.h"
// modify the following functions
// you can define global variables and functions
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<array<int, 2>> b;
vector<int> g[n];
for(int i=0; i<n; i++){
for(int l=0; l<n; l++){
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;
q.push_back({i, i, 1});
q.push_back({i, i, 1});
}
while(pos<q.size()){
auto [x, y, z]=q[pos];
if(vis[x][y][z]){ pos++; continue;}
vis[x][y][z]=1;
if(z==0){
if(val[x][y][z]==1)
for(auto i: g[y]){
c[x][i]++;
if(c[x][i]==g[i].size()){
q.push_back({x, i, 1});
}
}
}
else {
for(auto i: g[x]){
b[i][y]=x;
q.push_back({i, y, 0});
}
b[x][y]=x;
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:38: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]
38 | while(pos<q.size()){
| ~~~^~~~~~~~~
coprobber.cpp:47:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | 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... |