이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
const int N=1505;
vector<int> E[N];
int n;
int d[N];
vector<pair<int, int> > span;
bool bfs(int s){
vector<int> V={s};
d[s]=1;
vector<pair<int, int> > span2;
for(int i=0; i<V.size(); i++){
int v=V[i];
for(int u:E[v]){
if(!d[u]){
d[u]=d[v]+1;
V.push_back(u);
span2.push_back({min(u, v), max(u, v)});
}
}
}
for(int i:V)d[i]=0;
if(V.size()==n)span=span2;
return (V.size()==n);
}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
void initialize(int _n){
n=_n;
for(int i=0; i<n; i++){
for(int j=0; j<i; j++){
E[i].push_back(j);
E[j].push_back(i);
}
}
bfs(rng()%n);
}
int hasEdge(int u, int v) {
if(u>v)swap(u, v);
for(int &j:E[u])if(j==v)swap(j, E[u].back());
for(int &j:E[v])if(j==u)swap(j, E[v].back());
E[u].pop_back();
E[v].pop_back();
bool b=0;
for(auto j:span)if(j.st==u && j.nd==v)b=1;
if(!b)return 0;
if(bfs(rng()%n)){
return 0;
}
E[u].push_back(v);
E[v].push_back(u);
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
game.cpp: In function 'bool bfs(int)':
game.cpp:16:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i=0; i<V.size(); i++){
| ~^~~~~~~~~
game.cpp:27:13: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
27 | if(V.size()==n)span=span2;
| ~~~~~~~~^~~
game.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
28 | return (V.size()==n);
| ~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |