# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
49684 |
2018-06-02T07:22:57 Z |
강태규(#1275, imeimi2000) |
None (JOI16_snowy) |
C++11 |
|
41 ms |
38700 KB |
#include "Anyalib.h"
#include <algorithm>
#include <vector>
using namespace std;
const static int t = 11;
typedef pair<int, int> pii;
const static int MAXN = 500;
static int n;
static vector<pii> edge[MAXN];
static int s[MAXN], e[MAXN];
static pii close[MAXN];
static void dfs1(int x, int p, pii cl) {
if (cl.first > t) {
cl = pii(0, x);
}
close[x] = cl;
++cl.first;
for (pii i : edge[x]) {
if (i.second == p) continue;
dfs1(i.second, x, cl);
pii tp = close[i.second];
tp.first += 2;
cl = min(cl, tp);
}
}
static int dist[MAXN];
static int par[MAXN];
static void dfs2(int x, int p, int d, int C[]) {
dist[x] = d;
for (pii i : edge[x]) {
if (i.second == p) continue;
par[i.second] = C[i.first];
dfs2(i.second, x, d + C[i.first], C);
}
}
void InitAnya(int N , int A[] , int B[]) {
n = N;
for (int i = 0; i < n - 1; ++i) {
edge[A[i]].emplace_back(i, B[i]);
edge[B[i]].emplace_back(i, A[i]);
}
dfs1(0, -1, pii(20, -1));
int p = 0;
for (int i = 0; i < n; ++i) {
s[i] = p;
p = p + (close[i].first ? 1 : 10);
e[i] = p - 1;
}
}
void Anya(int C[]) {
dfs2(0, -1, 0, C);
for (int i = 0; i < n; ++i) {
Save(s[i], par[i]);
for (int j = s[i] + 1; j <= e[i]; ++j) {
Save(j, dist[i] & 1);
dist[i] >>= 1;
}
}
}
#include "Borislib.h"
#include <algorithm>
#include <vector>
using namespace std;
const static int t = 11;
typedef pair<int, int> pii;
const static int MAXN = 500;
static int n;
static vector<pii> edge[MAXN];
static int s[MAXN], e[MAXN];
static pii close[MAXN];
static int par[MAXN];
static int dep[MAXN];
static void dfs1(int x, int p, pii cl) {
par[x] = p;
if (cl.first > t) {
cl = pii(0, x);
}
close[x] = cl;
++cl.first;
for (pii i : edge[x]) {
if (i.second == p) continue;
dep[i.second] = dep[x] + 1;
dfs1(i.second, x, cl);
pii tp = close[i.second];
tp.first += 2;
cl = min(cl, tp);
}
}
void InitBoris(int N , int A[] , int B[]) {
n = N;
for (int i = 0; i < n - 1; ++i) {
edge[A[i]].emplace_back(i, B[i]);
edge[B[i]].emplace_back(i, A[i]);
}
dfs1(0, -1, pii(20, -1));
int p = 0;
for (int i = 0; i < n; ++i) {
s[i] = p;
p = p + (close[i].first ? 1 : 10);
e[i] = p - 1;
}
}
int Boris(int x) {
int y = close[x].second;
int ret = 0;
for (int i = e[y]; i > s[y]; --i) {
ret <<= 1;
ret += Ask(i);
}
while (dep[x] < dep[y]) {
ret -= Ask(s[y]);
y = par[y];
}
while (dep[x] > dep[y]) {
ret += Ask(s[x]);
x = par[x];
}
while (x != y) {
ret += Ask(s[x]) - Ask(s[y]);
x = par[x];
y = par[y];
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
876 KB |
Output is correct |
2 |
Correct |
5 ms |
1240 KB |
Output is correct |
3 |
Correct |
8 ms |
1272 KB |
Output is correct |
4 |
Correct |
8 ms |
1568 KB |
Output is correct |
5 |
Correct |
15 ms |
1844 KB |
Output is correct |
6 |
Correct |
12 ms |
1888 KB |
Output is correct |
7 |
Correct |
11 ms |
1888 KB |
Output is correct |
8 |
Correct |
12 ms |
1888 KB |
Output is correct |
9 |
Correct |
14 ms |
1888 KB |
Output is correct |
10 |
Correct |
11 ms |
1888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1888 KB |
Output is correct |
2 |
Correct |
13 ms |
1888 KB |
Output is correct |
3 |
Correct |
14 ms |
2048 KB |
Output is correct |
4 |
Correct |
16 ms |
2152 KB |
Output is correct |
5 |
Correct |
41 ms |
2328 KB |
Output is correct |
6 |
Correct |
14 ms |
2440 KB |
Output is correct |
7 |
Correct |
14 ms |
2552 KB |
Output is correct |
8 |
Correct |
15 ms |
2656 KB |
Output is correct |
9 |
Correct |
15 ms |
2776 KB |
Output is correct |
10 |
Correct |
15 ms |
2888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
3512 KB |
Output is correct |
2 |
Correct |
26 ms |
3912 KB |
Output is correct |
3 |
Correct |
31 ms |
4376 KB |
Output is correct |
4 |
Correct |
23 ms |
5016 KB |
Output is correct |
5 |
Correct |
28 ms |
5528 KB |
Output is correct |
6 |
Correct |
23 ms |
6040 KB |
Output is correct |
7 |
Correct |
23 ms |
6552 KB |
Output is correct |
8 |
Correct |
19 ms |
7192 KB |
Output is correct |
9 |
Correct |
21 ms |
7576 KB |
Output is correct |
10 |
Correct |
19 ms |
8096 KB |
Output is correct |
11 |
Correct |
21 ms |
8608 KB |
Output is correct |
12 |
Correct |
30 ms |
9252 KB |
Output is correct |
13 |
Correct |
28 ms |
9632 KB |
Output is correct |
14 |
Correct |
25 ms |
10144 KB |
Output is correct |
15 |
Correct |
23 ms |
10656 KB |
Output is correct |
16 |
Correct |
27 ms |
11168 KB |
Output is correct |
17 |
Correct |
27 ms |
11568 KB |
Output is correct |
18 |
Correct |
26 ms |
12192 KB |
Output is correct |
19 |
Correct |
27 ms |
12720 KB |
Output is correct |
20 |
Correct |
23 ms |
13216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
13728 KB |
Output is correct |
2 |
Correct |
24 ms |
14144 KB |
Output is correct |
3 |
Correct |
22 ms |
14912 KB |
Output is correct |
4 |
Correct |
27 ms |
15168 KB |
Output is correct |
5 |
Correct |
24 ms |
15680 KB |
Output is correct |
6 |
Correct |
17 ms |
16204 KB |
Output is correct |
7 |
Correct |
19 ms |
16704 KB |
Output is correct |
8 |
Correct |
18 ms |
17216 KB |
Output is correct |
9 |
Correct |
19 ms |
17728 KB |
Output is correct |
10 |
Correct |
18 ms |
18260 KB |
Output is correct |
11 |
Correct |
20 ms |
18760 KB |
Output is correct |
12 |
Correct |
20 ms |
19264 KB |
Output is correct |
13 |
Correct |
19 ms |
19776 KB |
Output is correct |
14 |
Correct |
21 ms |
20288 KB |
Output is correct |
15 |
Correct |
23 ms |
20800 KB |
Output is correct |
16 |
Correct |
22 ms |
21312 KB |
Output is correct |
17 |
Correct |
25 ms |
21776 KB |
Output is correct |
18 |
Correct |
24 ms |
22296 KB |
Output is correct |
19 |
Correct |
23 ms |
22808 KB |
Output is correct |
20 |
Correct |
23 ms |
23320 KB |
Output is correct |
21 |
Correct |
22 ms |
23832 KB |
Output is correct |
22 |
Correct |
37 ms |
24344 KB |
Output is correct |
23 |
Correct |
36 ms |
24856 KB |
Output is correct |
24 |
Correct |
24 ms |
25372 KB |
Output is correct |
25 |
Correct |
19 ms |
25816 KB |
Output is correct |
26 |
Correct |
19 ms |
26392 KB |
Output is correct |
27 |
Correct |
19 ms |
26904 KB |
Output is correct |
28 |
Correct |
18 ms |
27680 KB |
Output is correct |
29 |
Correct |
19 ms |
27936 KB |
Output is correct |
30 |
Correct |
19 ms |
28448 KB |
Output is correct |
31 |
Correct |
19 ms |
28832 KB |
Output is correct |
32 |
Correct |
18 ms |
29480 KB |
Output is correct |
33 |
Correct |
19 ms |
30240 KB |
Output is correct |
34 |
Correct |
18 ms |
30508 KB |
Output is correct |
35 |
Correct |
17 ms |
31008 KB |
Output is correct |
36 |
Correct |
20 ms |
31520 KB |
Output is correct |
37 |
Correct |
18 ms |
32032 KB |
Output is correct |
38 |
Correct |
20 ms |
32544 KB |
Output is correct |
39 |
Correct |
28 ms |
33072 KB |
Output is correct |
40 |
Correct |
18 ms |
33720 KB |
Output is correct |
41 |
Correct |
21 ms |
34104 KB |
Output is correct |
42 |
Correct |
18 ms |
34592 KB |
Output is correct |
43 |
Correct |
17 ms |
35104 KB |
Output is correct |
44 |
Correct |
18 ms |
35616 KB |
Output is correct |
45 |
Correct |
17 ms |
36128 KB |
Output is correct |
46 |
Correct |
25 ms |
36664 KB |
Output is correct |
47 |
Correct |
17 ms |
37168 KB |
Output is correct |
48 |
Correct |
18 ms |
37664 KB |
Output is correct |
49 |
Correct |
18 ms |
38176 KB |
Output is correct |
50 |
Correct |
17 ms |
38700 KB |
Output is correct |