# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
39810 |
2018-01-19T08:42:11 Z |
aome |
None (JOI16_snowy) |
C++14 |
|
24 ms |
4212 KB |
#include <bits/stdc++.h>
#include "Anyalib.h"
using namespace std;
namespace A {
const int N = 505;
typedef pair<int, int> ii;
int n;
int par[N];
int dis[N];
int high[N];
int edge[N];
int start[N];
vector<ii> G[N];
vector<int> v[N];
void dfs(int u) {
v[high[u] % 10].push_back(u);
for (auto v : G[u]) {
if (v.first == par[u]) continue;
high[v.first] = high[u] + 1, par[v.first] = u;
edge[v.second] = v.first, dfs(v.first);
}
}
void dfs2(int u) {
for (auto v : G[u]) {
if (v.first == par[u]) continue;
dis[v.first] += dis[u], dfs2(v.first);
}
}
void init(int _n, int A[], int B[]) {
n = _n;
for (int i = 0; i < (n - 1); ++i) {
G[A[i]].push_back(ii(B[i], i)), G[B[i]].push_back(ii(A[i], i));
}
dfs(0);
}
void solve(int C[]) {
for (int i = 0; i < (n - 1); ++i) dis[edge[i]] = C[i], Save(edge[i], C[i]);
dfs2(0);
int mn = 0;
for (int i = 1; i < 10; ++i) {
if (v[mn].size() > v[i].size()) mn = i;
}
int id = n;
for (auto i : v[mn]) {
start[i] = id;
for (int j = 0; j < 9; ++j) {
Save(id++, dis[i] >> j & 1);
}
}
}
}
void InitAnya(int N , int A[] , int B[]) { A::init(N, A, B); }
void Anya(int C[]) { A::solve(C); }
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
namespace B {
const int N = 505;
int n;
int par[N];
int high[N];
int start[N];
vector<int> G[N];
vector<int> v[N];
void dfs(int u) {
v[high[u] % 10].push_back(u);
for (auto v : G[u]) {
if (v == par[u]) continue;
high[v] = high[u] + 1, par[v] = u, dfs(v);
}
}
void init(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]);
}
dfs(0);
int mn = 0;
for (int i = 1; i < 10; ++i) {
if (v[mn].size() > v[i].size()) mn = i;
}
int id = n;
for (auto i : v[mn]) {
start[i] = id, id += 9;
}
}
int query(int x) {
int res = 0;
while (!start[x] && x) {
res += Ask(x), x = par[x];
}
if (start[x]) {
for (int i = 0; i < 9; ++i) res += Ask(start[x] + i) << i;
}
return res;
}
}
void InitBoris(int N , int A[] , int B[]) { B::init(N, A, B); }
int Boris(int x) { return B::query(x); }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4212 KB |
Output is correct |
2 |
Correct |
1 ms |
4212 KB |
Output is correct |
3 |
Correct |
3 ms |
4212 KB |
Output is correct |
4 |
Correct |
5 ms |
4212 KB |
Output is correct |
5 |
Correct |
7 ms |
4212 KB |
Output is correct |
6 |
Correct |
9 ms |
4212 KB |
Output is correct |
7 |
Correct |
2 ms |
4212 KB |
Output is correct |
8 |
Correct |
10 ms |
4212 KB |
Output is correct |
9 |
Correct |
7 ms |
4212 KB |
Output is correct |
10 |
Correct |
7 ms |
4212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4212 KB |
Output is correct |
2 |
Correct |
6 ms |
4212 KB |
Output is correct |
3 |
Correct |
8 ms |
4212 KB |
Output is correct |
4 |
Correct |
9 ms |
4212 KB |
Output is correct |
5 |
Correct |
6 ms |
4212 KB |
Output is correct |
6 |
Correct |
15 ms |
4212 KB |
Output is correct |
7 |
Correct |
8 ms |
4212 KB |
Output is correct |
8 |
Correct |
8 ms |
4212 KB |
Output is correct |
9 |
Correct |
5 ms |
4212 KB |
Output is correct |
10 |
Correct |
9 ms |
4212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
4212 KB |
Output is correct |
2 |
Correct |
24 ms |
4212 KB |
Output is correct |
3 |
Correct |
16 ms |
4212 KB |
Output is correct |
4 |
Correct |
13 ms |
4212 KB |
Output is correct |
5 |
Correct |
18 ms |
4212 KB |
Output is correct |
6 |
Correct |
19 ms |
4212 KB |
Output is correct |
7 |
Correct |
18 ms |
4212 KB |
Output is correct |
8 |
Correct |
19 ms |
4212 KB |
Output is correct |
9 |
Correct |
17 ms |
4212 KB |
Output is correct |
10 |
Correct |
19 ms |
4212 KB |
Output is correct |
11 |
Correct |
22 ms |
4212 KB |
Output is correct |
12 |
Correct |
21 ms |
4212 KB |
Output is correct |
13 |
Correct |
18 ms |
4212 KB |
Output is correct |
14 |
Correct |
19 ms |
4212 KB |
Output is correct |
15 |
Correct |
13 ms |
4212 KB |
Output is correct |
16 |
Correct |
17 ms |
4212 KB |
Output is correct |
17 |
Correct |
12 ms |
4212 KB |
Output is correct |
18 |
Correct |
10 ms |
4212 KB |
Output is correct |
19 |
Correct |
18 ms |
4212 KB |
Output is correct |
20 |
Correct |
19 ms |
4212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
4212 KB |
Output is correct |
2 |
Correct |
12 ms |
4212 KB |
Output is correct |
3 |
Correct |
15 ms |
4212 KB |
Output is correct |
4 |
Correct |
16 ms |
4212 KB |
Output is correct |
5 |
Correct |
18 ms |
4212 KB |
Output is correct |
6 |
Correct |
16 ms |
4212 KB |
Output is correct |
7 |
Correct |
18 ms |
4212 KB |
Output is correct |
8 |
Correct |
15 ms |
4212 KB |
Output is correct |
9 |
Correct |
15 ms |
4212 KB |
Output is correct |
10 |
Correct |
11 ms |
4212 KB |
Output is correct |
11 |
Correct |
22 ms |
4212 KB |
Output is correct |
12 |
Correct |
17 ms |
4212 KB |
Output is correct |
13 |
Correct |
15 ms |
4212 KB |
Output is correct |
14 |
Correct |
24 ms |
4212 KB |
Output is correct |
15 |
Correct |
18 ms |
4212 KB |
Output is correct |
16 |
Correct |
17 ms |
4212 KB |
Output is correct |
17 |
Correct |
11 ms |
4212 KB |
Output is correct |
18 |
Correct |
11 ms |
4212 KB |
Output is correct |
19 |
Correct |
12 ms |
4212 KB |
Output is correct |
20 |
Correct |
15 ms |
4212 KB |
Output is correct |
21 |
Correct |
13 ms |
4212 KB |
Output is correct |
22 |
Correct |
14 ms |
4212 KB |
Output is correct |
23 |
Correct |
13 ms |
4212 KB |
Output is correct |
24 |
Correct |
13 ms |
4212 KB |
Output is correct |
25 |
Correct |
14 ms |
4212 KB |
Output is correct |
26 |
Correct |
19 ms |
4212 KB |
Output is correct |
27 |
Correct |
17 ms |
4212 KB |
Output is correct |
28 |
Correct |
17 ms |
4212 KB |
Output is correct |
29 |
Correct |
12 ms |
4212 KB |
Output is correct |
30 |
Correct |
19 ms |
4212 KB |
Output is correct |
31 |
Correct |
17 ms |
4212 KB |
Output is correct |
32 |
Correct |
17 ms |
4212 KB |
Output is correct |
33 |
Correct |
13 ms |
4212 KB |
Output is correct |
34 |
Correct |
21 ms |
4212 KB |
Output is correct |
35 |
Correct |
13 ms |
4212 KB |
Output is correct |
36 |
Correct |
16 ms |
4212 KB |
Output is correct |
37 |
Correct |
13 ms |
4212 KB |
Output is correct |
38 |
Correct |
12 ms |
4212 KB |
Output is correct |
39 |
Correct |
13 ms |
4212 KB |
Output is correct |
40 |
Correct |
13 ms |
4212 KB |
Output is correct |
41 |
Correct |
9 ms |
4212 KB |
Output is correct |
42 |
Correct |
14 ms |
4212 KB |
Output is correct |
43 |
Correct |
15 ms |
4212 KB |
Output is correct |
44 |
Correct |
10 ms |
4212 KB |
Output is correct |
45 |
Correct |
13 ms |
4212 KB |
Output is correct |
46 |
Correct |
14 ms |
4212 KB |
Output is correct |
47 |
Correct |
10 ms |
4212 KB |
Output is correct |
48 |
Correct |
11 ms |
4212 KB |
Output is correct |
49 |
Correct |
11 ms |
4212 KB |
Output is correct |
50 |
Correct |
11 ms |
4212 KB |
Output is correct |