This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* https://oj.uz/problem/view/IOI14_game
* */
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>graph(1500,vector<int>(1500,0));
int N;
bool dfs(){
list<int>q;
vector<int>visited(N,0);
q.push_back(0);
visited[0]=1;
while(!q.empty()){
int x=q.front();
q.pop_front();
for(int i=0;i<N;i++){
if(x!=i&&graph[x][i]!=2&&!visited[i]){
q.push_back(i);
visited[i]=1;
}
}
}
return [&]()->bool{
for(int i=0;i<N;i++){
if(!visited[i]){
return false;
}
}
return true;
}();
}
void initialize(int n){
N=n;
}
int hasEdge(int u,int v){
graph[u][v]=2;
graph[v][u]=2;
if(dfs()){
return 0;
}else{
graph[u][v]=1;
graph[v][u]=1;
return 1;
}
}
// int main(){
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |