#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;
using ll = long long;
void Joi(int N, int M, int A[], int B[], long long X, int T) {
bool bio[N];
memset(bio, 0, sizeof bio);
int p = 0;
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]);
}
for (auto &v: adj) sort(begin(v), end(v));
function<void(int)> dfs = [&](int ver) {
bio[ver] = true;
MessageBoard(ver, (X >> p++) & 1);
p %= 60;
for (auto u: adj[ver]) if (!bio[u]) {
dfs(u);
}
};
dfs(0);
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
int limit = 20000;
if (T == 5) limit = 120;
else if (T == 4) limit = 960;
else if (T == 3) limit = 250;
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]);
}
for (auto &v: adj) sort(begin(v), end(v));
int col[N];
bool bio[N];
memset(bio, 0, sizeof bio);
int p = 0;
function<void(int)> dfsfind = [&](int ver) {
bio[ver] = true;
col[ver] = p++;
p %= 60;
for (auto u: adj[ver]) if (!bio[u]) {
dfsfind(u);
}
};
dfsfind(0);
memset(bio, 0, sizeof bio);
long long ans = (1ll * V) << col[P];
int cnt = 0;
function<void(int, int)> dfs = [&](int ver, int par) {
if (cnt >= limit) return;
bio[ver] = true;
for (auto u: adj[ver]) if (!bio[u]) {
if (cnt >= limit) return;
++cnt;
long long v = Move(u);
ans |= v << col[u];
dfs(u, ver);
}
if (cnt >= limit) return;
if (par != -1) {
++cnt;
assert(binary_search(begin(adj[ver]), end(adj[ver]), par));
Move(par);
}
};
dfs(P, -1);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
516 KB |
Output is correct |
2 |
Correct |
0 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
620 KB |
Output is correct |
4 |
Correct |
0 ms |
496 KB |
Output is correct |
5 |
Correct |
0 ms |
496 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
1 ms |
748 KB |
Output is correct |
8 |
Correct |
1 ms |
756 KB |
Output is correct |
9 |
Correct |
2 ms |
628 KB |
Output is correct |
10 |
Correct |
1 ms |
496 KB |
Output is correct |
11 |
Correct |
3 ms |
932 KB |
Output is correct |
12 |
Correct |
0 ms |
488 KB |
Output is correct |
13 |
Correct |
1 ms |
620 KB |
Output is correct |
14 |
Correct |
2 ms |
756 KB |
Output is correct |
15 |
Correct |
0 ms |
628 KB |
Output is correct |
16 |
Correct |
1 ms |
628 KB |
Output is correct |
17 |
Correct |
2 ms |
756 KB |
Output is correct |
18 |
Correct |
1 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
4028 KB |
Output is correct |
2 |
Correct |
29 ms |
4052 KB |
Output is correct |
3 |
Correct |
24 ms |
4000 KB |
Output is correct |
4 |
Correct |
18 ms |
2436 KB |
Output is correct |
5 |
Correct |
17 ms |
3404 KB |
Output is correct |
6 |
Correct |
15 ms |
2996 KB |
Output is correct |
7 |
Correct |
15 ms |
2864 KB |
Output is correct |
8 |
Correct |
14 ms |
2904 KB |
Output is correct |
9 |
Correct |
15 ms |
2936 KB |
Output is correct |
10 |
Correct |
13 ms |
2508 KB |
Output is correct |
11 |
Correct |
15 ms |
2488 KB |
Output is correct |
12 |
Correct |
13 ms |
2228 KB |
Output is correct |
13 |
Correct |
15 ms |
2216 KB |
Output is correct |
14 |
Correct |
14 ms |
2272 KB |
Output is correct |
15 |
Correct |
15 ms |
2380 KB |
Output is correct |
16 |
Correct |
14 ms |
2396 KB |
Output is correct |
17 |
Correct |
15 ms |
2464 KB |
Output is correct |
18 |
Correct |
15 ms |
2388 KB |
Output is correct |
19 |
Correct |
15 ms |
2416 KB |
Output is correct |
20 |
Correct |
11 ms |
3000 KB |
Output is correct |
21 |
Correct |
13 ms |
2908 KB |
Output is correct |
22 |
Correct |
17 ms |
2648 KB |
Output is correct |
23 |
Correct |
18 ms |
2844 KB |
Output is correct |
24 |
Correct |
15 ms |
2788 KB |
Output is correct |
25 |
Correct |
16 ms |
2716 KB |
Output is correct |
26 |
Correct |
14 ms |
2892 KB |
Output is correct |
27 |
Correct |
14 ms |
2896 KB |
Output is correct |
28 |
Correct |
15 ms |
2888 KB |
Output is correct |
29 |
Correct |
13 ms |
2652 KB |
Output is correct |
30 |
Correct |
18 ms |
2732 KB |
Output is correct |
31 |
Correct |
2 ms |
496 KB |
Output is correct |
32 |
Correct |
1 ms |
496 KB |
Output is correct |
33 |
Correct |
2 ms |
876 KB |
Output is correct |
34 |
Correct |
1 ms |
500 KB |
Output is correct |
35 |
Correct |
1 ms |
496 KB |
Output is correct |
36 |
Correct |
0 ms |
496 KB |
Output is correct |
37 |
Correct |
0 ms |
468 KB |
Output is correct |
38 |
Correct |
2 ms |
496 KB |
Output is correct |
39 |
Correct |
0 ms |
496 KB |
Output is correct |
40 |
Correct |
2 ms |
488 KB |
Output is correct |
41 |
Correct |
0 ms |
488 KB |
Output is correct |
42 |
Correct |
0 ms |
500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
488 KB |
Output is correct |
2 |
Correct |
1 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
1028 KB |
Output is correct |
5 |
Correct |
2 ms |
1028 KB |
Output is correct |
6 |
Correct |
2 ms |
1040 KB |
Output is correct |
7 |
Correct |
3 ms |
1044 KB |
Output is correct |
8 |
Correct |
2 ms |
1032 KB |
Output is correct |
9 |
Correct |
10 ms |
3496 KB |
Output is correct |
10 |
Correct |
10 ms |
3584 KB |
Output is correct |
11 |
Correct |
9 ms |
3520 KB |
Output is correct |
12 |
Correct |
1 ms |
496 KB |
Output is correct |
13 |
Correct |
1 ms |
500 KB |
Output is correct |
14 |
Correct |
2 ms |
488 KB |
Output is correct |
15 |
Correct |
0 ms |
488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
30 ms |
3768 KB |
Partially correct |
2 |
Partially correct |
20 ms |
3740 KB |
Partially correct |
3 |
Partially correct |
22 ms |
3816 KB |
Partially correct |
4 |
Partially correct |
13 ms |
2384 KB |
Partially correct |
5 |
Partially correct |
12 ms |
3248 KB |
Partially correct |
6 |
Partially correct |
12 ms |
2904 KB |
Partially correct |
7 |
Partially correct |
15 ms |
2804 KB |
Partially correct |
8 |
Partially correct |
13 ms |
2636 KB |
Partially correct |
9 |
Partially correct |
15 ms |
2756 KB |
Partially correct |
10 |
Partially correct |
16 ms |
2496 KB |
Partially correct |
11 |
Partially correct |
12 ms |
2484 KB |
Partially correct |
12 |
Partially correct |
11 ms |
2216 KB |
Partially correct |
13 |
Partially correct |
11 ms |
2232 KB |
Partially correct |
14 |
Partially correct |
11 ms |
2224 KB |
Partially correct |
15 |
Partially correct |
13 ms |
2376 KB |
Partially correct |
16 |
Partially correct |
12 ms |
2392 KB |
Partially correct |
17 |
Partially correct |
16 ms |
2368 KB |
Partially correct |
18 |
Partially correct |
12 ms |
2424 KB |
Partially correct |
19 |
Partially correct |
13 ms |
2364 KB |
Partially correct |
20 |
Incorrect |
9 ms |
3008 KB |
Wrong Answer [7] |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
3712 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |