이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |