#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]; bool vis[N];
int p[N], in[N], timer = 0;
void init(int u) {
in[u] = timer;
if (++timer == B) timer = 0;
for (int v : g[u]) {
g[v].erase(find(all(g[v]), u));
p[v] = u;
init(v);
}
}
ll U = (1ll << B) - 1, cur = 0, x = 0;
bool dfs(int u, ll z) {
vis[u] = true;
assert(~cur & 1ll << in[u]);
cur |= 1ll << in[u];
x |= z << in[u];
if (cur == U) return true;
for (int v : g[u]) {
if (vis[v]) continue;
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); while (!dfs(P, V)) V = Move(p[P]), P = p[P];
return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
2300 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 |
27 ms |
4004 KB |
Output is correct |
2 |
Runtime error |
28 ms |
5540 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1544 KB |
Output is correct |
2 |
Correct |
2 ms |
1684 KB |
Output is correct |
3 |
Correct |
4 ms |
1664 KB |
Output is correct |
4 |
Correct |
5 ms |
1844 KB |
Output is correct |
5 |
Correct |
4 ms |
2000 KB |
Output is correct |
6 |
Correct |
4 ms |
1972 KB |
Output is correct |
7 |
Correct |
3 ms |
1972 KB |
Output is correct |
8 |
Correct |
4 ms |
1972 KB |
Output is correct |
9 |
Correct |
16 ms |
4372 KB |
Output is correct |
10 |
Correct |
17 ms |
4268 KB |
Output is correct |
11 |
Correct |
14 ms |
4324 KB |
Output is correct |
12 |
Correct |
2 ms |
1672 KB |
Output is correct |
13 |
Correct |
2 ms |
1544 KB |
Output is correct |
14 |
Correct |
2 ms |
1544 KB |
Output is correct |
15 |
Correct |
2 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
4156 KB |
Output is correct |
2 |
Runtime error |
33 ms |
5568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
4148 KB |
Output is correct |
2 |
Runtime error |
32 ms |
5576 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |