# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
39836 |
2018-01-20T15:25:56 Z |
cheater2k |
None (JOI16_snowy) |
C++14 |
|
27 ms |
4188 KB |
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
namespace A {
const int N = 505;
int n;
int dep[N];
int snowy[N];
int w[N]; // for edges
int mod;
int where[N];
vector< pair<int,int> > G[N];
vector<int> cand;
void dfs(int u, int p) {
for (auto e : G[u]) {
int v = e.second; if (v == p) continue;
dep[v] = dep[u] + 1;
dfs(v, u);
}
}
void redfs(int u, int p) {
for (auto e : G[u]) {
int id = e.first, v = e.second; if (v == p) continue;
snowy[v] = snowy[u] + w[id];
redfs(v, u);
}
}
void init() {
dfs(0, 0);
vector<int> buf[10];
for (int i = 0; i < n; ++i) {
buf[dep[i] % 10].push_back(i);
}
mod = 0;
for (int i = 1; i < 10; ++i) {
if (buf[i].size() < buf[mod].size()) mod = i;
}
cand = buf[mod];
}
void solve() {
for (int i = 0; i < n; ++i) snowy[i] = 0;
redfs(0, 0);
// save the edges into bits from 0 to N - 2
for (int i = 0; i < n - 1; ++i) {
Save(i, w[i]);
}
// save the "snowy" values of the vertices that are candidates
// each has 9 bits
int cur = n - 1;
for (int u : cand) {
where[u] = cur;
for (int i = 0; i < 9; ++i) {
Save(cur, snowy[u] >> i & 1); ++cur;
}
}
assert(cur < 1000);
}
}
void InitAnya(int N , int A[] , int B[]) {
A::n = N;
for (int i = 0; i < N - 1; ++i) {
A::G[A[i]].push_back(make_pair(i, B[i]));
A::G[B[i]].push_back(make_pair(i, A[i]));
}
A::init();
}
void Anya(int C[]) {
for (int i = 0; i < A::n - 1; ++i) {
A::w[i] = C[i];
}
A::solve();
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
namespace B {
const int N = 505;
int n;
int par[N], topar[N];
int dep[N];
int w[N]; // for edges
int mod;
int where[N];
vector< pair<int,int> > G[N];
vector<int> cand;
void dfs(int u) {
for (auto e : G[u]) {
int v = e.second; if (v == par[u]) continue;
par[v] = u;
topar[v] = e.first;
dep[v] = dep[u] + 1;
dfs(v);
}
}
void init() {
dfs(0);
vector<int> buf[10];
for (int i = 0; i < n; ++i) {
buf[dep[i] % 10].push_back(i);
}
mod = 0;
for (int i = 1; i < 10; ++i) {
if (buf[i].size() < buf[mod].size()) mod = i;
}
cand = buf[mod];
// where
int cur = n - 1;
for (int u : cand) {
where[u] = cur; cur += 9;
}
}
int solve(int u) {
int ret = 0;
while(u && dep[u] % 10 != mod) {
ret += Ask(topar[u]); u = par[u];
}
if (dep[u] % 10 == mod) {
int start = where[u];
int cur = 0;
for (int i = start; i < start + 9; ++i) {
cur += (1 << (i - start)) * Ask(i);
}
ret += cur;
}
return ret;
}
}
void InitBoris(int N , int A[] , int B[]) {
B::n = N;
for (int i = 0; i < N - 1; ++i) {
B::G[A[i]].push_back(make_pair(i, B[i]));
B::G[B[i]].push_back(make_pair(i, A[i]));
}
B::init();
}
int Boris(int city) {
return B::solve(city);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4188 KB |
Output is correct |
2 |
Correct |
1 ms |
4188 KB |
Output is correct |
3 |
Correct |
4 ms |
4188 KB |
Output is correct |
4 |
Correct |
4 ms |
4188 KB |
Output is correct |
5 |
Correct |
4 ms |
4188 KB |
Output is correct |
6 |
Correct |
7 ms |
4188 KB |
Output is correct |
7 |
Correct |
10 ms |
4188 KB |
Output is correct |
8 |
Correct |
13 ms |
4188 KB |
Output is correct |
9 |
Correct |
4 ms |
4188 KB |
Output is correct |
10 |
Correct |
7 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4188 KB |
Output is correct |
2 |
Correct |
12 ms |
4188 KB |
Output is correct |
3 |
Correct |
8 ms |
4188 KB |
Output is correct |
4 |
Correct |
9 ms |
4188 KB |
Output is correct |
5 |
Correct |
9 ms |
4188 KB |
Output is correct |
6 |
Correct |
8 ms |
4188 KB |
Output is correct |
7 |
Correct |
10 ms |
4188 KB |
Output is correct |
8 |
Correct |
6 ms |
4188 KB |
Output is correct |
9 |
Correct |
9 ms |
4188 KB |
Output is correct |
10 |
Correct |
10 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
4188 KB |
Output is correct |
2 |
Correct |
22 ms |
4188 KB |
Output is correct |
3 |
Correct |
16 ms |
4188 KB |
Output is correct |
4 |
Correct |
18 ms |
4188 KB |
Output is correct |
5 |
Correct |
24 ms |
4188 KB |
Output is correct |
6 |
Correct |
21 ms |
4188 KB |
Output is correct |
7 |
Correct |
23 ms |
4188 KB |
Output is correct |
8 |
Correct |
20 ms |
4188 KB |
Output is correct |
9 |
Correct |
13 ms |
4188 KB |
Output is correct |
10 |
Correct |
15 ms |
4188 KB |
Output is correct |
11 |
Correct |
19 ms |
4188 KB |
Output is correct |
12 |
Correct |
22 ms |
4188 KB |
Output is correct |
13 |
Correct |
19 ms |
4188 KB |
Output is correct |
14 |
Correct |
18 ms |
4188 KB |
Output is correct |
15 |
Correct |
18 ms |
4188 KB |
Output is correct |
16 |
Correct |
27 ms |
4188 KB |
Output is correct |
17 |
Correct |
18 ms |
4188 KB |
Output is correct |
18 |
Correct |
21 ms |
4188 KB |
Output is correct |
19 |
Correct |
21 ms |
4188 KB |
Output is correct |
20 |
Correct |
18 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
4188 KB |
Output is correct |
2 |
Correct |
17 ms |
4188 KB |
Output is correct |
3 |
Correct |
13 ms |
4188 KB |
Output is correct |
4 |
Correct |
17 ms |
4188 KB |
Output is correct |
5 |
Correct |
18 ms |
4188 KB |
Output is correct |
6 |
Correct |
16 ms |
4188 KB |
Output is correct |
7 |
Correct |
19 ms |
4188 KB |
Output is correct |
8 |
Correct |
13 ms |
4188 KB |
Output is correct |
9 |
Correct |
17 ms |
4188 KB |
Output is correct |
10 |
Correct |
13 ms |
4188 KB |
Output is correct |
11 |
Correct |
17 ms |
4188 KB |
Output is correct |
12 |
Correct |
16 ms |
4188 KB |
Output is correct |
13 |
Correct |
14 ms |
4188 KB |
Output is correct |
14 |
Correct |
17 ms |
4188 KB |
Output is correct |
15 |
Correct |
17 ms |
4188 KB |
Output is correct |
16 |
Correct |
15 ms |
4188 KB |
Output is correct |
17 |
Correct |
13 ms |
4188 KB |
Output is correct |
18 |
Correct |
12 ms |
4188 KB |
Output is correct |
19 |
Correct |
23 ms |
4188 KB |
Output is correct |
20 |
Correct |
16 ms |
4188 KB |
Output is correct |
21 |
Correct |
18 ms |
4188 KB |
Output is correct |
22 |
Correct |
13 ms |
4188 KB |
Output is correct |
23 |
Correct |
14 ms |
4188 KB |
Output is correct |
24 |
Correct |
19 ms |
4188 KB |
Output is correct |
25 |
Correct |
16 ms |
4188 KB |
Output is correct |
26 |
Correct |
18 ms |
4188 KB |
Output is correct |
27 |
Correct |
18 ms |
4188 KB |
Output is correct |
28 |
Correct |
20 ms |
4188 KB |
Output is correct |
29 |
Correct |
15 ms |
4188 KB |
Output is correct |
30 |
Correct |
17 ms |
4188 KB |
Output is correct |
31 |
Correct |
17 ms |
4188 KB |
Output is correct |
32 |
Correct |
19 ms |
4188 KB |
Output is correct |
33 |
Correct |
20 ms |
4188 KB |
Output is correct |
34 |
Correct |
16 ms |
4188 KB |
Output is correct |
35 |
Correct |
21 ms |
4188 KB |
Output is correct |
36 |
Correct |
15 ms |
4188 KB |
Output is correct |
37 |
Correct |
19 ms |
4188 KB |
Output is correct |
38 |
Correct |
13 ms |
4188 KB |
Output is correct |
39 |
Correct |
16 ms |
4188 KB |
Output is correct |
40 |
Correct |
13 ms |
4188 KB |
Output is correct |
41 |
Correct |
18 ms |
4188 KB |
Output is correct |
42 |
Correct |
9 ms |
4188 KB |
Output is correct |
43 |
Correct |
12 ms |
4188 KB |
Output is correct |
44 |
Correct |
13 ms |
4188 KB |
Output is correct |
45 |
Correct |
15 ms |
4188 KB |
Output is correct |
46 |
Correct |
19 ms |
4188 KB |
Output is correct |
47 |
Correct |
16 ms |
4188 KB |
Output is correct |
48 |
Correct |
16 ms |
4188 KB |
Output is correct |
49 |
Correct |
16 ms |
4188 KB |
Output is correct |
50 |
Correct |
16 ms |
4188 KB |
Output is correct |