#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const int N = 500;
int n;
int pr[N], c[N];
vector<int> cands;
vector<array<int, 2>> g[N];
int dfs(int u) {
int cur = 0;
for (auto [v, i] : g[u]) {
if (v != pr[u]) {
pr[v] = u;
cur = max(cur, dfs(v));
}
}
if (cur == 11) {
cands.push_back(u);
cur = 0;
}
return cur + 1;
}
void color(int u, int *C) {
for (auto [v, i] : g[u]) {
if (v != pr[u]) {
Save(v, C[i]);
c[v] = c[u] + C[i];
color(v, C);
}
}
}
}
void InitAnya(int N, int *A, int *B) {
n = N;
for (int i = 0; i < N - 1; ++i) {
g[A[i]].push_back({B[i], i});
g[B[i]].push_back({A[i], i});
}
dfs(0);
}
void Anya(int *C) {
c[0] = 0;
color(0, C);
for (int i = 0; i < cands.size(); ++i) {
for (int j = 0; j < 9; ++j) {
Save(500 + i * 9 + j, c[cands[i]] >> j & 1);
}
}
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const int N = 500;
int n, p = 0;
int pr[N], spec[N];
vector<int> g[N];
int dfs(int u) {
int cur = 0;
for (int v : g[u]) {
if (v != pr[u]) {
pr[v] = u;
cur = max(cur, dfs(v));
}
}
if (cur == 11) {
spec[u] = ++p;
cur = 0;
}
return cur + 1;
}
}
void InitBoris(int N, int *A, int *B) {
n = N;
for (int i = 0; i < N - 1; ++i) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
pr[0] = -1;
dfs(0);
}
int Boris(int u) {
int res = 0;
while (~u && !spec[u]) {
res += Ask(u);
u = pr[u];
}
if (spec[u]) {
for (int j = 0; j < 9; ++j) {
res += Ask(500 + 9 * (spec[u] - 1) + j) << j;
}
}
return res;
}
Compilation message
Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:53:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for (int i = 0; i < cands.size(); ++i) {
| ~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
784 KB |
Output is correct |
2 |
Correct |
0 ms |
804 KB |
Output is correct |
3 |
Correct |
2 ms |
840 KB |
Output is correct |
4 |
Correct |
2 ms |
1232 KB |
Output is correct |
5 |
Correct |
3 ms |
1200 KB |
Output is correct |
6 |
Correct |
4 ms |
1196 KB |
Output is correct |
7 |
Correct |
5 ms |
1196 KB |
Output is correct |
8 |
Correct |
3 ms |
1184 KB |
Output is correct |
9 |
Correct |
4 ms |
1196 KB |
Output is correct |
10 |
Correct |
3 ms |
1184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1200 KB |
Output is correct |
2 |
Correct |
5 ms |
1200 KB |
Output is correct |
3 |
Correct |
4 ms |
1200 KB |
Output is correct |
4 |
Correct |
4 ms |
1200 KB |
Output is correct |
5 |
Correct |
5 ms |
1300 KB |
Output is correct |
6 |
Correct |
4 ms |
1192 KB |
Output is correct |
7 |
Correct |
5 ms |
1192 KB |
Output is correct |
8 |
Correct |
5 ms |
1200 KB |
Output is correct |
9 |
Correct |
5 ms |
1184 KB |
Output is correct |
10 |
Correct |
4 ms |
1196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
1208 KB |
Output is correct |
2 |
Correct |
12 ms |
1224 KB |
Output is correct |
3 |
Correct |
9 ms |
1212 KB |
Output is correct |
4 |
Correct |
9 ms |
1216 KB |
Output is correct |
5 |
Correct |
9 ms |
1228 KB |
Output is correct |
6 |
Correct |
8 ms |
1216 KB |
Output is correct |
7 |
Correct |
9 ms |
1212 KB |
Output is correct |
8 |
Correct |
10 ms |
1224 KB |
Output is correct |
9 |
Correct |
9 ms |
1224 KB |
Output is correct |
10 |
Correct |
9 ms |
1168 KB |
Output is correct |
11 |
Correct |
8 ms |
1216 KB |
Output is correct |
12 |
Correct |
12 ms |
1348 KB |
Output is correct |
13 |
Correct |
10 ms |
1216 KB |
Output is correct |
14 |
Correct |
11 ms |
1212 KB |
Output is correct |
15 |
Correct |
9 ms |
1216 KB |
Output is correct |
16 |
Correct |
10 ms |
1224 KB |
Output is correct |
17 |
Correct |
9 ms |
1212 KB |
Output is correct |
18 |
Correct |
9 ms |
1224 KB |
Output is correct |
19 |
Correct |
9 ms |
1216 KB |
Output is correct |
20 |
Correct |
8 ms |
1316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1676 KB |
Output is correct |
2 |
Correct |
9 ms |
1736 KB |
Output is correct |
3 |
Correct |
8 ms |
1720 KB |
Output is correct |
4 |
Correct |
9 ms |
1728 KB |
Output is correct |
5 |
Correct |
10 ms |
1728 KB |
Output is correct |
6 |
Correct |
8 ms |
1800 KB |
Output is correct |
7 |
Correct |
10 ms |
1728 KB |
Output is correct |
8 |
Correct |
8 ms |
1720 KB |
Output is correct |
9 |
Correct |
9 ms |
1752 KB |
Output is correct |
10 |
Correct |
8 ms |
1728 KB |
Output is correct |
11 |
Correct |
9 ms |
1732 KB |
Output is correct |
12 |
Correct |
7 ms |
1724 KB |
Output is correct |
13 |
Correct |
11 ms |
1724 KB |
Output is correct |
14 |
Correct |
9 ms |
1732 KB |
Output is correct |
15 |
Correct |
9 ms |
1732 KB |
Output is correct |
16 |
Correct |
8 ms |
1692 KB |
Output is correct |
17 |
Correct |
9 ms |
1732 KB |
Output is correct |
18 |
Correct |
8 ms |
1676 KB |
Output is correct |
19 |
Correct |
9 ms |
1728 KB |
Output is correct |
20 |
Correct |
9 ms |
1720 KB |
Output is correct |
21 |
Correct |
9 ms |
1724 KB |
Output is correct |
22 |
Correct |
9 ms |
1980 KB |
Output is correct |
23 |
Correct |
9 ms |
1724 KB |
Output is correct |
24 |
Correct |
9 ms |
1732 KB |
Output is correct |
25 |
Correct |
9 ms |
1732 KB |
Output is correct |
26 |
Correct |
9 ms |
1724 KB |
Output is correct |
27 |
Correct |
9 ms |
1700 KB |
Output is correct |
28 |
Correct |
9 ms |
1732 KB |
Output is correct |
29 |
Correct |
9 ms |
1728 KB |
Output is correct |
30 |
Correct |
9 ms |
1732 KB |
Output is correct |
31 |
Correct |
9 ms |
1724 KB |
Output is correct |
32 |
Correct |
7 ms |
1728 KB |
Output is correct |
33 |
Correct |
9 ms |
1724 KB |
Output is correct |
34 |
Correct |
7 ms |
1728 KB |
Output is correct |
35 |
Correct |
8 ms |
1792 KB |
Output is correct |
36 |
Correct |
9 ms |
1732 KB |
Output is correct |
37 |
Correct |
8 ms |
1720 KB |
Output is correct |
38 |
Correct |
10 ms |
1732 KB |
Output is correct |
39 |
Correct |
6 ms |
1716 KB |
Output is correct |
40 |
Correct |
8 ms |
1720 KB |
Output is correct |
41 |
Correct |
8 ms |
1728 KB |
Output is correct |
42 |
Correct |
7 ms |
1728 KB |
Output is correct |
43 |
Correct |
9 ms |
1728 KB |
Output is correct |
44 |
Correct |
8 ms |
1728 KB |
Output is correct |
45 |
Correct |
8 ms |
1728 KB |
Output is correct |
46 |
Correct |
7 ms |
1720 KB |
Output is correct |
47 |
Correct |
7 ms |
1720 KB |
Output is correct |
48 |
Correct |
7 ms |
1716 KB |
Output is correct |
49 |
Correct |
8 ms |
1728 KB |
Output is correct |
50 |
Correct |
7 ms |
1844 KB |
Output is correct |