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>
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<char, int> ci;
typedef pair<string, int> si;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
#define pb push_back
#define fi first
#define se second
#define whole(v) v.begin(), v.end()
#define rwhole(v) v.rbegin(), v.rend()
#define inf INT_MAX/2
#define fro front
int len[1501];
int f[1501];
int aris[1501][1501];
int n;
int ffather(int i){
if(f[i] == i){
return i;
}
return ffather(f[i]);
}
void join(int u, int v){
u = ffather(u);
v = ffather(v);
if(u == v){
return;
}
if(len[u] > len[v]){
swap(u, v);
}
f[u] = v;
len[v] += len[u];
for(int i = 1; i <= n; ++i){
aris[v][i] += aris[u][i];
aris[i][v] += aris[i][u];
}
}
void initialize(int N) {
n = N;
for(int i = 1; i <= n; ++i){
f[i] = i;
len[i] = 1;
}
}
int hasEdge(int u, int v){
u++;
v++;
u = ffather(u);
v = ffather(v);
aris[u][v]++;
aris[v][u]++;
if(aris[u][v] == len[u] * len[v]){
join(u, v);
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... |