This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int N;
vector<int> parents(1502);
vector<int> connected(1502,1);
vector<set<int>> asked(1502,set<int>());
int find_parent(int pos){
if(parents[pos] == pos){
return pos;
}return find_parent(parents[pos]);
}
void initialize(int n) {
for(int i=0;i<n;i++){
parents[i] = i;
asked[i].insert(i);
}
N = n;
}
int hasEdge(int u, int v) {
if(u==v){
return 1;
}
// cout << "u size " << asked[u].size() << " " << u << " " << v << " " << find_parent(u) << endl;
// if(find_parent(u) == v)
// return 1;
// if(find_parent(v) == u)
// return 1;
connected[u]++;
connected[v]++;
if(connected[u]<connected[v]){
swap(u,v);
}
// cout << "u-"<<u << " v-" << v << " c[u]-" << connected[u] << " c[v]-" << connected[v] << endl;
if(connected[u] == N){
return 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |