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 <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 12, MOD = 998244353;
typedef long long ll;
#include "game.h"
int _n;
//int read_int() {
// int x;
// assert(scanf("%d", &x) == 1);
// return x;
//}
set<int> g[N];
int p[N],sz[N];
void initialize(int n) {
_n = n;
for(int i = 0;i < n;i++){
p[i] = i;
sz[i] = 1;
}
for(int i = 0;i < n;i++){
p[i] = i;
for(int j = 0;j < n;j++){
g[i].insert(j);
}
}
}
int col[2002][2002];
int get(int v){
if(p[v] == v) return v;
return p[v] = get(p[v]);
}
void merge(int a,int b){
a = get(a);
b = get(b);
p[a] = b;
sz[b] += sz[a];
for(int i = 0;i < _n;i++){
col[i][b] += col[i][a];
col[b][i] += col[a][i];
}
}
int hasEdge(int u, int v) {
u = get(u);
v = get(v);
if (u == v) return 1;
if(u > v) swap(u,v);
col[u][v]++;
col[v][u]++;
if(col[u][v] == sz[u] * sz[v]){
merge(u,v);
return 1;
}
return 0;
}
//int main() {
// int n, u, v;
// n = read_int();
// initialize(n);
// for (int i = 0; i < n * (n - 1) / 2; i++) {
// u = read_int();
// v = read_int();
// if (hasEdge(u, v)) {
// puts("1");
// }
// else puts("0");
// }
// 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... |