This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// SB Solution
#include "game.h"
#define N 1501
#define M 2048
int n, nn, d[M*2], tree_cnt[M*2];
void initialize(int _n) {
n = _n;
for (nn = 1; nn < n; nn *= 2);
for (int i = 1; i <= n; i++) tree_cnt[nn + i - 1] = 1;
for (int i = nn - 1; i >= 1; i--) {
tree_cnt[i] = tree_cnt[i * 2] + tree_cnt[i * 2 + 1];
d[i] = tree_cnt[i * 2] * tree_cnt[i * 2 + 1];
}
}
int hasEdge(int x, int y) {
x += nn, y += nn;
while (x != y) {
if (x > y) x /= 2;
else y /= 2;
} d[x]--;
return d[x] ? 0 : 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |