# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494034 | TeaTime | Game (IOI14_game) | C++17 | 455 ms | 39876 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 <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <tuple>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
const ll SZ = 2000;
ll dsu[SZ], add[SZ][SZ], nn;
int par(int v) {
if (dsu[v] == v) return dsu[v];
return dsu[v] = par(dsu[v]);
}
void uni(int v, int u) {
v = par(v);
u = par(u);
if (u != v) {
dsu[u] = v;
for (int i = 0; i < nn; i++) {
add[v][i] += add[u][i];
add[i][v] += add[u][i];
}
}
}
void initialize(int n) {
for (int i = 0; i < n; i++) dsu[i] = i;
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) add[i][j] = 1;
nn = n;
}
int hasEdge(int u, int v) {
if (u > v) swap(u, v);
int n = nn;
u = par(u);
v = par(v);
int cnt = add[u][v];
if (cnt == 1) {
uni(u, v);
return 1;
}
add[u][v]--;
add[v][u]--;
return 0;
}
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... |