# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
595220 | birthdaycake | Game (IOI14_game) | C++17 | 25 ms | 47208 KiB |
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<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
using namespace std;
vector<int>adj[2000001];
int dsu[2000001],rnk[2000001];
set<pair<int,int>>d;
int N;
int Find(int x){
if(dsu[x] == x) return x;
return dsu[x] = Find(dsu[x]);
}
void Unite(int a, int b){
a = Find(a); b = Find(b);
if(rnk[a] < rnk[b]) swap(a,b);
if(rnk[a] == rnk[b]) rnk[a]++;
dsu[b] = a;
}
void initialize(int n) {
N = n;
for(int i = 0; i < n; i++) dsu[i] = i;
}
int hasEdge(int u, int v) {
int set_a = Find(u), set_b = Find(v);
if(set_a == set_b) return 0;
vector<int>x,y;
for(int i = 0; i < N; i++){
if(Find(i) == set_a) x.push_back(i);
if(Find(i) == set_b) y.push_back(i);
}
for(int i = 0; i < x.size(); i++){
for(int j = 0; j < y.size(); j++){
if(!d.count({x[i],y[i]})) return 0;
}
}
d.insert({u,v});
d.insert({v,u});
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |