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 long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1507;
int F[LIM], ile[LIM][LIM];
int n;
int fnd(int x) {
if(F[x]==x) return x;
return F[x]=fnd(F[x]);
}
void uni(int a, int b) {
rep(i, n) if(fnd(i)==i) {
ile[fnd(a)][i]+=ile[fnd(b)][i];
ile[i][fnd(a)]=ile[fnd(a)][i];
}
F[fnd(b)]=fnd(a);
}
void initialize(int N) {
n=N;
rep(i, n) {
F[i]=i;
rep(j, n) ile[i][j]=1;
}
}
int hasEdge(int u, int v) {
if(fnd(u)==fnd(v)) return 0;
if(ile[fnd(u)][fnd(v)]==1) {
uni(u, v);
return 1;
}
--ile[fnd(u)][fnd(v)];
--ile[fnd(v)][fnd(u)];
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... |