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;
using i32 = int;
using i64 = long long;
template <typename T>
using Vec = vector<T>;
#define OVERRIDE4(a, b, c, d, ...) d
#define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i, m, n) for (i32 i = (i32)(m); i < (i32)(n); ++i)
#define REP(...) OVERRIDE4(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define ALL(x) begin(x), end(x)
#define PER(i, n) for (i32 i = (i32)(n) - 1; i >= 0; --i)
template <typename T>
bool chmin(T &x, const T &y) {
if (x > y) {
x = y;
return true;
} else {
return false;
}
}
template <typename T>
bool chmax(T &x, const T &y) {
if (x < y) {
x = y;
return true;
} else {
return false;
}
}
constexpr i32 INF = 1001001001;
constexpr i64 INF64 = 3003003003003003003;
class UnionFindWithCounter {
Vec<i32> par;
Vec<i32> cnt;
i32 root(i32 x) {
if (par[x] < 0) {
return x;
} else {
return par[x] = root(par[x]);
}
}
public:
UnionFindWithCounter() = default;
UnionFindWithCounter(i32 n) : par(n, -1), cnt(n, 0) {}
bool same(i32 x, i32 y) {
x = root(x);
y = root(y);
return x == y;
}
void unite(i32 x, i32 y) {
x = root(x);
y = root(y);
if (x == y) {
return;
}
if (-par[x] > -par[y]) {
swap(x, y);
}
cnt[y] += cnt[x];
cnt[x] = 0;
par[y] += par[x];
par[x] = y;
}
void increase(i32 x) {
x = root(x);
++cnt[x];
}
i32 access(i32 x) {
x = root(x);
return cnt[x];
}
i32 size(i32 x) {
x = root(x);
return -par[x];
}
};
mt19937 mt(998244353);
i32 m;
Vec<i32> deg;
//UnionFindWithCounter uf;
void initialize(int n) {
m = n;
deg = Vec<i32>(m, m - 1);
//uf = UnionFindWithCounter(m);
}
int hasEdge(int u, int v) {
--deg[u];
--deg[v];
if (deg[u] == 0 || deg[v] == 0) {
return 1;
} else {
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... |