#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
using ll = long long;
namespace {
const int N = 1 << 14, B = 60;
int nxt[N];
int head(int u) { return nxt[u] != u ? nxt[u] = head(nxt[u]) : u; }
bool unite(int u, int v) {
u = head(u); v = head(v);
if (u == v) return 0;
nxt[u] = v; return 1;
}
vector<int> g[N];
int timer = 0; ll x;
void dfs(int u, int p) {
MessageBoard(u, x >> timer & 1);
if (++timer == B) timer = 0;
for (int v : g[u]) if (v != p) dfs(v, u);
}
}
void Joi(int n, int m, int a[], int b[], ll X, int t) {
rep(u, 0, n) nxt[u] = u;
rep(e, 0, m) {
if (unite(a[e], b[e])) {
g[a[e]].push_back(b[e]);
g[b[e]].push_back(a[e]);
}
}
x = X; dfs(0, -1);
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
using ll = long long;
namespace {
const int N = 1 << 14, B = 60;
int nxt[N];
int head(int u) { return nxt[u] != u ? nxt[u] = head(nxt[u]) : u; }
bool unite(int u, int v) {
u = head(u); v = head(v);
if (u == v) return 0;
nxt[u] = v; return 1;
}
vector<int> g[N];
int p[N], in[N], out[N], timer = 0;
void init(int u) {
in[u] = timer++;
for (int v : g[u]) {
g[v].erase(find(all(g[v]), u));
p[v] = u; init(v);
}
out[u] = timer;
}
ll cur = 0, x = 0;
bool add(int u, ll z) {
int s = in[u] % B;
cur |= 1ll << s;
x |= z << s;
return __builtin_popcountll(cur) == B;
}
bool dfs(int u, int z) {
if (add(u, z)) return true;
for (int v : g[u]) {
if (dfs(v, Move(v))) return true;
Move(u);
}
return false;
}
}
ll Ioi(int n, int m, int a[], int b[], int P, int V, int T) {
rep(u, 0, n) nxt[u] = u;
rep(e, 0, m) {
if (unite(a[e], b[e])) {
g[a[e]].push_back(b[e]);
g[b[e]].push_back(a[e]);
}
}
init(0);
int u = P;
while (u && out[P] - in[u] < B) u = p[u];
if (B <= out[P] - in[u]) {
while (P != u) {
if (add(P, V)) break;
V = Move(p[P]), P = p[P];
}
dfs(P, V);
} else assert(false);
return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
2180 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
3812 KB |
Output is correct |
2 |
Correct |
29 ms |
3812 KB |
Output is correct |
3 |
Correct |
27 ms |
3812 KB |
Output is correct |
4 |
Correct |
17 ms |
3308 KB |
Output is correct |
5 |
Correct |
17 ms |
3660 KB |
Output is correct |
6 |
Correct |
19 ms |
3780 KB |
Output is correct |
7 |
Correct |
17 ms |
3532 KB |
Output is correct |
8 |
Correct |
19 ms |
3660 KB |
Output is correct |
9 |
Correct |
18 ms |
3532 KB |
Output is correct |
10 |
Correct |
17 ms |
3368 KB |
Output is correct |
11 |
Correct |
15 ms |
3276 KB |
Output is correct |
12 |
Correct |
15 ms |
3132 KB |
Output is correct |
13 |
Correct |
16 ms |
3132 KB |
Output is correct |
14 |
Correct |
16 ms |
3140 KB |
Output is correct |
15 |
Correct |
18 ms |
3188 KB |
Output is correct |
16 |
Correct |
20 ms |
3148 KB |
Output is correct |
17 |
Correct |
19 ms |
3400 KB |
Output is correct |
18 |
Correct |
20 ms |
3148 KB |
Output is correct |
19 |
Correct |
17 ms |
3020 KB |
Output is correct |
20 |
Correct |
16 ms |
3660 KB |
Output is correct |
21 |
Correct |
13 ms |
3660 KB |
Output is correct |
22 |
Correct |
22 ms |
3492 KB |
Output is correct |
23 |
Correct |
17 ms |
3660 KB |
Output is correct |
24 |
Correct |
20 ms |
3404 KB |
Output is correct |
25 |
Correct |
26 ms |
3532 KB |
Output is correct |
26 |
Correct |
20 ms |
3744 KB |
Output is correct |
27 |
Correct |
17 ms |
3532 KB |
Output is correct |
28 |
Correct |
18 ms |
3532 KB |
Output is correct |
29 |
Correct |
17 ms |
3388 KB |
Output is correct |
30 |
Correct |
15 ms |
3536 KB |
Output is correct |
31 |
Correct |
2 ms |
1540 KB |
Output is correct |
32 |
Correct |
2 ms |
1788 KB |
Output is correct |
33 |
Correct |
2 ms |
1548 KB |
Output is correct |
34 |
Runtime error |
3 ms |
2308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1668 KB |
Output is correct |
2 |
Correct |
2 ms |
1788 KB |
Output is correct |
3 |
Correct |
2 ms |
1784 KB |
Output is correct |
4 |
Correct |
4 ms |
2008 KB |
Output is correct |
5 |
Correct |
4 ms |
2128 KB |
Output is correct |
6 |
Correct |
3 ms |
2124 KB |
Output is correct |
7 |
Correct |
3 ms |
2016 KB |
Output is correct |
8 |
Correct |
3 ms |
2012 KB |
Output is correct |
9 |
Correct |
14 ms |
4376 KB |
Output is correct |
10 |
Correct |
15 ms |
4380 KB |
Output is correct |
11 |
Correct |
13 ms |
4300 KB |
Output is correct |
12 |
Correct |
2 ms |
1784 KB |
Output is correct |
13 |
Correct |
2 ms |
1540 KB |
Output is correct |
14 |
Correct |
2 ms |
1784 KB |
Output is correct |
15 |
Correct |
2 ms |
1540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
3904 KB |
Output is correct |
2 |
Correct |
28 ms |
3684 KB |
Output is correct |
3 |
Correct |
29 ms |
3904 KB |
Output is correct |
4 |
Correct |
17 ms |
3396 KB |
Output is correct |
5 |
Correct |
17 ms |
3916 KB |
Output is correct |
6 |
Partially correct |
17 ms |
3732 KB |
Partially correct |
7 |
Correct |
16 ms |
3752 KB |
Output is correct |
8 |
Correct |
17 ms |
3404 KB |
Output is correct |
9 |
Correct |
16 ms |
3404 KB |
Output is correct |
10 |
Correct |
15 ms |
3276 KB |
Output is correct |
11 |
Correct |
15 ms |
3384 KB |
Output is correct |
12 |
Correct |
16 ms |
3004 KB |
Output is correct |
13 |
Correct |
15 ms |
3132 KB |
Output is correct |
14 |
Correct |
16 ms |
3184 KB |
Output is correct |
15 |
Correct |
17 ms |
3148 KB |
Output is correct |
16 |
Correct |
17 ms |
3160 KB |
Output is correct |
17 |
Correct |
18 ms |
3404 KB |
Output is correct |
18 |
Partially correct |
17 ms |
3020 KB |
Partially correct |
19 |
Correct |
17 ms |
3160 KB |
Output is correct |
20 |
Correct |
13 ms |
3660 KB |
Output is correct |
21 |
Correct |
13 ms |
3704 KB |
Output is correct |
22 |
Correct |
17 ms |
3532 KB |
Output is correct |
23 |
Correct |
17 ms |
3660 KB |
Output is correct |
24 |
Correct |
17 ms |
3532 KB |
Output is correct |
25 |
Correct |
16 ms |
3740 KB |
Output is correct |
26 |
Correct |
17 ms |
3532 KB |
Output is correct |
27 |
Correct |
17 ms |
3724 KB |
Output is correct |
28 |
Correct |
17 ms |
3404 KB |
Output is correct |
29 |
Correct |
15 ms |
3436 KB |
Output is correct |
30 |
Correct |
17 ms |
3396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
3896 KB |
Output is correct |
2 |
Correct |
27 ms |
3812 KB |
Output is correct |
3 |
Correct |
27 ms |
3900 KB |
Output is correct |
4 |
Correct |
16 ms |
3400 KB |
Output is correct |
5 |
Correct |
17 ms |
3916 KB |
Output is correct |
6 |
Correct |
17 ms |
3656 KB |
Output is correct |
7 |
Correct |
16 ms |
3424 KB |
Output is correct |
8 |
Correct |
17 ms |
3732 KB |
Output is correct |
9 |
Correct |
16 ms |
3660 KB |
Output is correct |
10 |
Correct |
15 ms |
3372 KB |
Output is correct |
11 |
Correct |
15 ms |
3276 KB |
Output is correct |
12 |
Correct |
15 ms |
3208 KB |
Output is correct |
13 |
Correct |
16 ms |
3132 KB |
Output is correct |
14 |
Correct |
16 ms |
3012 KB |
Output is correct |
15 |
Correct |
17 ms |
3148 KB |
Output is correct |
16 |
Correct |
22 ms |
3160 KB |
Output is correct |
17 |
Correct |
20 ms |
3180 KB |
Output is correct |
18 |
Incorrect |
16 ms |
3404 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |