#include <bits/stdc++.h>
using namespace std;
#include <Joi.h>
void Joi(int n, int m, int *a, int *b, long long x, int t) {
vector<vector<int>> adj(n);
for (int i = 0; i < m; ++i) {
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
}
vector<bool> visited(n);
auto dfs = [&](int u, auto &self) -> void {
MessageBoard(u, x % 2);
x /= 2;
visited[u] = true;
for (auto c : adj[u]) {
if (!visited[c]) {
self(c, self);
}
}
};
dfs(0, dfs);
}
#include <bits/stdc++.h>
using namespace std;
#include <Ioi.h>
const int L = 60;
long long Ioi(int n, int m, int *a, int *b, int p, int v, int t) {
vector<vector<int>> adj(n);
for (int i = 0; i < m; ++i) {
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
}
vector<int> path;
vector<bool> visited(n);
auto dfs_find = [&](int u, auto &self) -> bool {
visited[u] = true;
if (u == 0) {
return true;
}
for (auto c : adj[u]) {
if (!visited[c] && self(c, self)) {
path.push_back(c);
return true;
}
}
return false;
};
dfs_find(p, dfs_find);
reverse(path.begin(), path.end());
for (auto u : path) {
v = Move(u);
}
long long ans = 0, bit = 1;
visited.assign(n, false);
auto dfs_read = [&](int u, auto &self) -> bool {
ans += v * bit;
bit *= 2;
if (__lg(bit) == L) {
return true;
}
visited[u] = true;
for (auto c : adj[u]) {
if (!visited[c]) {
v = Move(c);
if (self(c, self)) {
return true;
}
v = Move(u);
}
}
return false;
};
dfs_read(0, dfs_read);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
496 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
624 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
2 ms |
624 KB |
Output is correct |
8 |
Correct |
2 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
624 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
5 ms |
952 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
2 ms |
596 KB |
Output is correct |
14 |
Correct |
3 ms |
636 KB |
Output is correct |
15 |
Correct |
2 ms |
624 KB |
Output is correct |
16 |
Correct |
2 ms |
624 KB |
Output is correct |
17 |
Correct |
2 ms |
624 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
3384 KB |
Output is correct |
2 |
Correct |
26 ms |
3696 KB |
Output is correct |
3 |
Correct |
25 ms |
3460 KB |
Output is correct |
4 |
Correct |
15 ms |
2420 KB |
Output is correct |
5 |
Correct |
15 ms |
2736 KB |
Output is correct |
6 |
Correct |
16 ms |
2604 KB |
Output is correct |
7 |
Correct |
15 ms |
2604 KB |
Output is correct |
8 |
Correct |
14 ms |
2556 KB |
Output is correct |
9 |
Correct |
15 ms |
2716 KB |
Output is correct |
10 |
Correct |
14 ms |
2588 KB |
Output is correct |
11 |
Correct |
14 ms |
2616 KB |
Output is correct |
12 |
Correct |
14 ms |
2260 KB |
Output is correct |
13 |
Correct |
14 ms |
2320 KB |
Output is correct |
14 |
Correct |
14 ms |
2432 KB |
Output is correct |
15 |
Correct |
14 ms |
2412 KB |
Output is correct |
16 |
Correct |
14 ms |
2472 KB |
Output is correct |
17 |
Correct |
14 ms |
2484 KB |
Output is correct |
18 |
Correct |
14 ms |
2476 KB |
Output is correct |
19 |
Correct |
15 ms |
2460 KB |
Output is correct |
20 |
Correct |
12 ms |
2724 KB |
Output is correct |
21 |
Correct |
12 ms |
2688 KB |
Output is correct |
22 |
Correct |
15 ms |
2596 KB |
Output is correct |
23 |
Correct |
15 ms |
2668 KB |
Output is correct |
24 |
Correct |
15 ms |
2592 KB |
Output is correct |
25 |
Correct |
15 ms |
2600 KB |
Output is correct |
26 |
Correct |
14 ms |
2720 KB |
Output is correct |
27 |
Correct |
15 ms |
2712 KB |
Output is correct |
28 |
Correct |
15 ms |
2716 KB |
Output is correct |
29 |
Correct |
14 ms |
2436 KB |
Output is correct |
30 |
Correct |
14 ms |
2448 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
596 KB |
Output is correct |
33 |
Correct |
2 ms |
624 KB |
Output is correct |
34 |
Correct |
2 ms |
492 KB |
Output is correct |
35 |
Correct |
2 ms |
492 KB |
Output is correct |
36 |
Correct |
2 ms |
620 KB |
Output is correct |
37 |
Correct |
2 ms |
504 KB |
Output is correct |
38 |
Correct |
2 ms |
492 KB |
Output is correct |
39 |
Correct |
2 ms |
492 KB |
Output is correct |
40 |
Correct |
2 ms |
492 KB |
Output is correct |
41 |
Correct |
2 ms |
492 KB |
Output is correct |
42 |
Correct |
2 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
500 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
3 ms |
904 KB |
Output is correct |
5 |
Incorrect |
3 ms |
920 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
3412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
3320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |