# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422488 | flappybird | Game (IOI14_game) | C++14 | 1 ms | 332 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 "game.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef int ll;
#define MAX 1900
ll N;
ll p[MAX];
ll line[MAX][MAX];
ll num[MAX];
ll find(ll x) {
if (x == p[x]) return x;
return p[x] = find(p[x]);
}
void uni(ll x, ll y) {
x = find(x);
y = find(y);
ll i;
p[y] = x;
num[x] += num[y];
for (i = 0; i < N; i++) if (i != x && i != y) line[i][x] += line[i][y];
}
void initialize(int n) {
N = n;
ll i, j;
for (i = 0; i < N; i++) p[i] = i, num[i] = 1;
}
int hasEdge(int u, int v) {
u = find(u);
v = find(v);
if (u == v) return 1;
if (line[u][v] == num[u] * num[v] - 1) {
uni(u, v);
return 1;
}
line[u][v]++;
line[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... |