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>
#define fi first
#define se second
using namespace std;
int n;
vector<int> cnt, adj, val;
int aux = 0;
void initialize(int N) {
n = N;
cnt = vector<int>(n, 0);
adj = vector<int>(n);
val = vector<int>(n, -1);
}
int hasEdge(int u, int v) {
if (val[u] == -1) {
val[u] = aux;
++aux;
}
if (val[v] == -1) {
val[v] = aux;
++aux;
}
if (cnt[val[u]]+cnt[val[v]] == 0) {
++cnt[val[u]]; ++cnt[val[v]];
adj[max(val[u], val[v])] = min(val[u], val[v]);
return 1;
}
if (cnt[val[u]]+cnt[adj[val[u]]] == 2*(n-1)-1 || cnt[val[v]]+cnt[adj[val[v]]] == 2*(n-1)-1) {
++cnt[val[u]]; ++cnt[val[v]];
return 1;
}
++cnt[val[u]]; ++cnt[val[v]];
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... |