# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1082663 |
2024-09-01T04:45:34 Z |
Zero_OP |
JOI tour (JOI24_joitour) |
C++17 |
|
1448 ms |
197036 KB |
#include "joitour.h"
#include "bits/stdc++.h"
#define dbg(x) "[" << #x << " = " << (x) << "]"
using namespace std;
const int MAX = 2e5 + 5;
const int num10 = 0;
const int num12 = 1;
const int num0 = 2;
const int num2 = 3;
const int num1 = 4;
int N, a[MAX], par[MAX], depth[MAX], tin[18][MAX], tout[18][MAX], sz[MAX], id_subtree[18][MAX], timer_subtree, timer_dfs;
vector<int> adj[MAX];
bool used[MAX];
long long cnt_total[4][MAX], cnt_subtree[4][MAX], num_ways[MAX], ans;
//num_ways mean case f[c] = 1
struct Fenwick{
vector<int> bit;
Fenwick(int n) : bit(n + 1, 0) {}
Fenwick() : bit() {}
void update(int id, int val){
for(; id < (int)bit.size(); id += id & (-id)){
bit[id] += val;
}
}
int query(int id){
int sum = 0;
for(; id > 0; id -= id & (-id)){
sum += bit[id];
}
return sum;
}
void updateRange(int l, int r, int val){
update(l, val);
update(r + 1, -val);
}
int queryRange(int l, int r){
return query(r) - query(l - 1);
}
};
Fenwick ft[5][MAX];
int dfs_size(int u, int pre){
sz[u] = 1;
for(int v : adj[u]) if(v != pre && !used[v]){
sz[u] += dfs_size(v, u);
}
return sz[u];
}
int find_centroid(int u, int pre, int target){
for(int v : adj[u]) if(v != pre && !used[v] && sz[v] > (target / 2)){
return find_centroid(v, u, target);
}
return u;
}
int c;
void dfs_subtree(int u, int pre, int layer){
tin[layer][u] = ++timer_dfs;
id_subtree[layer][u] = timer_subtree;
if(a[u] == 0){
ft[num0][c].update(tin[layer][u], +1);
++cnt_total[num0][c];
++cnt_subtree[num0][timer_subtree];
} else if(a[u] == 2){
ft[num2][c].update(tin[layer][u], +1);
++cnt_total[num2][c];
++cnt_subtree[num2][timer_subtree];
}
for(int v : adj[u]) if(v != pre && !used[v]){
dfs_subtree(v, u, layer);
if(pre == -1) ++timer_subtree;
}
tout[layer][u] = timer_dfs;
if(a[u] == 1){
ft[num1][c].updateRange(tin[layer][u], tout[layer][u], +1);
int cnt10 = ft[num0][c].queryRange(tin[layer][u], tout[layer][u]);
int cnt12 = ft[num2][c].queryRange(tin[layer][u], tout[layer][u]);
cnt_subtree[num10][timer_subtree] += cnt10;
cnt_subtree[num12][timer_subtree] += cnt12;
cnt_total[num10][c] += cnt10;
cnt_total[num12][c] += cnt12;
}
}
void decompose(int u, int layer, int p){
int size = dfs_size(u, -1);
u = find_centroid(u, -1, size);
used[u] = true;
par[u] = p;
depth[u] = layer;
ft[num10][u] = Fenwick(size);
ft[num12][u] = Fenwick(size);
ft[num0][u] = Fenwick(size);
ft[num1][u] = Fenwick(size);
ft[num2][u] = Fenwick(size);
c = u;
timer_dfs = 0;
for(int v : adj[u]) if(!used[v]){
dfs_subtree(v, u, layer);
num_ways[u] -= cnt_subtree[num0][timer_subtree] * cnt_subtree[num2][timer_subtree];
ans -= cnt_subtree[num0][timer_subtree] * cnt_subtree[num12][timer_subtree];
ans -= cnt_subtree[num2][timer_subtree] * cnt_subtree[num10][timer_subtree];
++timer_subtree;
}
num_ways[u] += cnt_total[num0][u] * cnt_total[num2][u];
ans += cnt_total[num0][u] * cnt_total[num12][u];
ans += cnt_total[num2][u] * cnt_total[num10][u];
if(a[u] == 0) ans += cnt_total[num12][u];
if(a[u] == 1) ans += num_ways[u];
if(a[u] == 2) ans += cnt_total[num10][u];
for(int v : adj[u]) if(!used[v]){
decompose(v, layer + 1, u);
}
}
void init(int N, std::vector<int> F, std::vector<int> U, std::vector<int> V, int Q) {
::N = N;
for(int i = 0; i < N; ++i) a[i] = F[i];
for(int i = 0; i < N - 1; ++i){
int u = U[i], v = V[i];
adj[u].push_back(v);
adj[v].push_back(u);
}
decompose(0, 0, -1);
}
void change(int u, int nval) {
if(a[u] == nval) return;
int dep = depth[u], c = u;
while(c != -1){
if(c == u){
if(a[u] == 0) ans -= cnt_total[num12][u];
if(a[u] == 1) ans -= num_ways[u];
if(a[u] == 2) ans -= cnt_total[num10][u];
if(nval == 0) ans += cnt_total[num12][u];
if(nval == 1) ans += num_ways[u];
if(nval == 2) ans += cnt_total[num10][u];
} else{
int id = id_subtree[dep][u];
///remove data
if(a[c] == 0) ans -= cnt_total[num12][c];
if(a[c] == 1) ans -= num_ways[c];
if(a[c] == 2) ans -= cnt_total[num10][c];
num_ways[c] += cnt_subtree[num0][id] * cnt_subtree[num2][id];
ans += cnt_subtree[num0][id] * cnt_subtree[num12][id];
ans += cnt_subtree[num2][id] * cnt_subtree[num10][id];
num_ways[c] -= cnt_total[num0][c] * cnt_total[num2][c];
ans -= cnt_total[num0][c] * cnt_total[num12][c];
ans -= cnt_total[num2][c] * cnt_total[num10][c];
if(a[u] == 0){
int contribution = ft[num1][c].query(tin[dep][u]);
cnt_subtree[num10][id] -= contribution;
--cnt_subtree[num0][id];
cnt_total[num10][c] -= contribution;
--cnt_total[num0][c];
ft[num0][c].update(tin[dep][u], -1);
} else if(a[u] == 1){
int cnt10 = ft[num0][c].queryRange(tin[dep][u], tout[dep][u]);
int cnt12 = ft[num2][c].queryRange(tin[dep][u], tout[dep][u]);
cnt_subtree[num10][id] -= cnt10;
cnt_subtree[num12][id] -= cnt12;
cnt_total[num10][c] -= cnt10;
cnt_total[num12][c] -= cnt12;
ft[num1][c].updateRange(tin[dep][u], tout[dep][u], -1);
} else{
int contribution = ft[num1][c].query(tin[dep][u]);
cnt_subtree[num12][id] -= contribution;
--cnt_subtree[num2][id];
cnt_total[num12][c] -= contribution;
--cnt_total[num2][c];
ft[num2][c].update(tin[dep][u], -1);
}
//end remove data
//replace data
if(nval == 0){
int contribution = ft[num1][c].query(tin[dep][u]);
cnt_subtree[num10][id] += contribution;
++cnt_subtree[num0][id];
cnt_total[num10][c] += contribution;
++cnt_total[num0][c];
ft[num0][c].update(tin[dep][u], +1);
} else if(nval == 1){
int cnt10 = ft[num0][c].queryRange(tin[dep][u], tout[dep][u]);
int cnt12 = ft[num2][c].queryRange(tin[dep][u], tout[dep][u]);
cnt_subtree[num10][id] += cnt10;
cnt_subtree[num12][id] += cnt12;
cnt_total[num10][c] += cnt10;
cnt_total[num12][c] += cnt12;
ft[num1][c].updateRange(tin[dep][u], tout[dep][u], +1);
} else{
int contribution = ft[num1][c].query(tin[dep][u]);
cnt_subtree[num12][id] += contribution;
++cnt_subtree[num2][id];
cnt_total[num12][c] += contribution;
++cnt_total[num2][c];
ft[num2][c].update(tin[dep][u], +1);
}
num_ways[c] += cnt_total[num0][c] * cnt_total[num2][c];
ans += cnt_total[num0][c] * cnt_total[num12][c];
ans += cnt_total[num2][c] * cnt_total[num10][c];
num_ways[c] -= cnt_subtree[num0][id] * cnt_subtree[num2][id];
ans -= cnt_subtree[num0][id] * cnt_subtree[num12][id];
ans -= cnt_subtree[num2][id] * cnt_subtree[num10][id];
if(a[c] == 0) ans += cnt_total[num12][c];
if(a[c] == 1) ans += num_ways[c];
if(a[c] == 2) ans += cnt_total[num10][c];
//end replace data
}
c = par[c]; --dep;
}
a[u] = nval;
}
long long num_tours() {
return ans;
}
/*
Test 1 :
Input
3
0 1 2
0 1
1 2
0
Output :
1
Test 2 :
Input :
3
0 1 2
0 1
1 2
2
2 0
0 2
Output
1
0
1
Test 3 :
Input :
7
1 0 2 2 0 1 0
0 1
0 2
1 3
1 4
2 5
2 6
7
0 0
1 1
2 0
3 0
4 2
5 2
6 2
Ouptut : 3
0
4
4
0
4
5
5
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
30040 KB |
Output is correct |
2 |
Correct |
12 ms |
30040 KB |
Output is correct |
3 |
Correct |
12 ms |
30128 KB |
Output is correct |
4 |
Correct |
12 ms |
30296 KB |
Output is correct |
5 |
Correct |
10 ms |
30040 KB |
Output is correct |
6 |
Correct |
13 ms |
30040 KB |
Output is correct |
7 |
Correct |
11 ms |
30040 KB |
Output is correct |
8 |
Correct |
12 ms |
30040 KB |
Output is correct |
9 |
Correct |
11 ms |
30296 KB |
Output is correct |
10 |
Correct |
11 ms |
30040 KB |
Output is correct |
11 |
Correct |
11 ms |
30040 KB |
Output is correct |
12 |
Correct |
12 ms |
30040 KB |
Output is correct |
13 |
Correct |
11 ms |
30040 KB |
Output is correct |
14 |
Correct |
10 ms |
30040 KB |
Output is correct |
15 |
Correct |
12 ms |
29932 KB |
Output is correct |
16 |
Correct |
12 ms |
30040 KB |
Output is correct |
17 |
Correct |
11 ms |
30040 KB |
Output is correct |
18 |
Correct |
11 ms |
30040 KB |
Output is correct |
19 |
Correct |
11 ms |
30384 KB |
Output is correct |
20 |
Correct |
13 ms |
30040 KB |
Output is correct |
21 |
Correct |
12 ms |
30040 KB |
Output is correct |
22 |
Correct |
12 ms |
30136 KB |
Output is correct |
23 |
Correct |
11 ms |
30040 KB |
Output is correct |
24 |
Correct |
11 ms |
30296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
30040 KB |
Output is correct |
2 |
Correct |
12 ms |
30040 KB |
Output is correct |
3 |
Correct |
12 ms |
30128 KB |
Output is correct |
4 |
Correct |
12 ms |
30296 KB |
Output is correct |
5 |
Correct |
10 ms |
30040 KB |
Output is correct |
6 |
Correct |
13 ms |
30040 KB |
Output is correct |
7 |
Correct |
11 ms |
30040 KB |
Output is correct |
8 |
Correct |
12 ms |
30040 KB |
Output is correct |
9 |
Correct |
11 ms |
30296 KB |
Output is correct |
10 |
Correct |
11 ms |
30040 KB |
Output is correct |
11 |
Correct |
11 ms |
30040 KB |
Output is correct |
12 |
Correct |
12 ms |
30040 KB |
Output is correct |
13 |
Correct |
11 ms |
30040 KB |
Output is correct |
14 |
Correct |
10 ms |
30040 KB |
Output is correct |
15 |
Correct |
12 ms |
29932 KB |
Output is correct |
16 |
Correct |
12 ms |
30040 KB |
Output is correct |
17 |
Correct |
11 ms |
30040 KB |
Output is correct |
18 |
Correct |
11 ms |
30040 KB |
Output is correct |
19 |
Correct |
11 ms |
30384 KB |
Output is correct |
20 |
Correct |
13 ms |
30040 KB |
Output is correct |
21 |
Correct |
12 ms |
30040 KB |
Output is correct |
22 |
Correct |
12 ms |
30136 KB |
Output is correct |
23 |
Correct |
11 ms |
30040 KB |
Output is correct |
24 |
Correct |
11 ms |
30296 KB |
Output is correct |
25 |
Correct |
22 ms |
32600 KB |
Output is correct |
26 |
Correct |
22 ms |
32344 KB |
Output is correct |
27 |
Correct |
24 ms |
31116 KB |
Output is correct |
28 |
Correct |
21 ms |
32856 KB |
Output is correct |
29 |
Correct |
20 ms |
32344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
30040 KB |
Output is correct |
2 |
Correct |
810 ms |
190484 KB |
Output is correct |
3 |
Correct |
834 ms |
189808 KB |
Output is correct |
4 |
Correct |
738 ms |
188076 KB |
Output is correct |
5 |
Correct |
856 ms |
190800 KB |
Output is correct |
6 |
Correct |
308 ms |
178000 KB |
Output is correct |
7 |
Correct |
308 ms |
178000 KB |
Output is correct |
8 |
Correct |
657 ms |
179004 KB |
Output is correct |
9 |
Correct |
684 ms |
178072 KB |
Output is correct |
10 |
Correct |
656 ms |
175268 KB |
Output is correct |
11 |
Correct |
667 ms |
170152 KB |
Output is correct |
12 |
Correct |
743 ms |
186192 KB |
Output is correct |
13 |
Correct |
781 ms |
186276 KB |
Output is correct |
14 |
Correct |
656 ms |
185972 KB |
Output is correct |
15 |
Correct |
783 ms |
185424 KB |
Output is correct |
16 |
Correct |
818 ms |
194128 KB |
Output is correct |
17 |
Correct |
12 ms |
30040 KB |
Output is correct |
18 |
Correct |
12 ms |
30040 KB |
Output is correct |
19 |
Correct |
12 ms |
29928 KB |
Output is correct |
20 |
Correct |
11 ms |
30040 KB |
Output is correct |
21 |
Correct |
664 ms |
165312 KB |
Output is correct |
22 |
Correct |
687 ms |
165288 KB |
Output is correct |
23 |
Correct |
577 ms |
166224 KB |
Output is correct |
24 |
Correct |
660 ms |
167248 KB |
Output is correct |
25 |
Correct |
260 ms |
89628 KB |
Output is correct |
26 |
Correct |
248 ms |
89540 KB |
Output is correct |
27 |
Correct |
287 ms |
89604 KB |
Output is correct |
28 |
Correct |
254 ms |
89624 KB |
Output is correct |
29 |
Correct |
373 ms |
196688 KB |
Output is correct |
30 |
Correct |
400 ms |
196944 KB |
Output is correct |
31 |
Correct |
330 ms |
196760 KB |
Output is correct |
32 |
Correct |
413 ms |
196836 KB |
Output is correct |
33 |
Correct |
357 ms |
174520 KB |
Output is correct |
34 |
Correct |
364 ms |
174416 KB |
Output is correct |
35 |
Correct |
315 ms |
174512 KB |
Output is correct |
36 |
Correct |
361 ms |
174416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
30040 KB |
Output is correct |
2 |
Correct |
11 ms |
30040 KB |
Output is correct |
3 |
Correct |
13 ms |
30108 KB |
Output is correct |
4 |
Correct |
11 ms |
30040 KB |
Output is correct |
5 |
Correct |
12 ms |
30040 KB |
Output is correct |
6 |
Correct |
14 ms |
30040 KB |
Output is correct |
7 |
Correct |
12 ms |
30296 KB |
Output is correct |
8 |
Correct |
21 ms |
32856 KB |
Output is correct |
9 |
Correct |
377 ms |
196776 KB |
Output is correct |
10 |
Correct |
362 ms |
196780 KB |
Output is correct |
11 |
Correct |
322 ms |
196944 KB |
Output is correct |
12 |
Correct |
362 ms |
196788 KB |
Output is correct |
13 |
Correct |
336 ms |
110784 KB |
Output is correct |
14 |
Correct |
336 ms |
110648 KB |
Output is correct |
15 |
Correct |
422 ms |
110676 KB |
Output is correct |
16 |
Correct |
415 ms |
110708 KB |
Output is correct |
17 |
Correct |
382 ms |
110620 KB |
Output is correct |
18 |
Correct |
421 ms |
111008 KB |
Output is correct |
19 |
Correct |
758 ms |
196944 KB |
Output is correct |
20 |
Correct |
715 ms |
196944 KB |
Output is correct |
21 |
Correct |
948 ms |
196792 KB |
Output is correct |
22 |
Correct |
983 ms |
197036 KB |
Output is correct |
23 |
Correct |
866 ms |
196760 KB |
Output is correct |
24 |
Correct |
945 ms |
196944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
30040 KB |
Output is correct |
2 |
Correct |
11 ms |
30040 KB |
Output is correct |
3 |
Correct |
11 ms |
30040 KB |
Output is correct |
4 |
Correct |
11 ms |
30040 KB |
Output is correct |
5 |
Correct |
10 ms |
30040 KB |
Output is correct |
6 |
Correct |
12 ms |
30296 KB |
Output is correct |
7 |
Correct |
21 ms |
32344 KB |
Output is correct |
8 |
Correct |
331 ms |
174464 KB |
Output is correct |
9 |
Correct |
358 ms |
174520 KB |
Output is correct |
10 |
Correct |
308 ms |
174416 KB |
Output is correct |
11 |
Correct |
339 ms |
174500 KB |
Output is correct |
12 |
Correct |
320 ms |
99152 KB |
Output is correct |
13 |
Correct |
410 ms |
99152 KB |
Output is correct |
14 |
Correct |
408 ms |
99240 KB |
Output is correct |
15 |
Correct |
405 ms |
99328 KB |
Output is correct |
16 |
Correct |
374 ms |
99152 KB |
Output is correct |
17 |
Correct |
423 ms |
99300 KB |
Output is correct |
18 |
Correct |
750 ms |
174416 KB |
Output is correct |
19 |
Correct |
920 ms |
174420 KB |
Output is correct |
20 |
Correct |
888 ms |
174416 KB |
Output is correct |
21 |
Correct |
876 ms |
174552 KB |
Output is correct |
22 |
Correct |
780 ms |
174416 KB |
Output is correct |
23 |
Correct |
879 ms |
174500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
30040 KB |
Output is correct |
2 |
Correct |
12 ms |
30040 KB |
Output is correct |
3 |
Correct |
12 ms |
30128 KB |
Output is correct |
4 |
Correct |
12 ms |
30296 KB |
Output is correct |
5 |
Correct |
10 ms |
30040 KB |
Output is correct |
6 |
Correct |
13 ms |
30040 KB |
Output is correct |
7 |
Correct |
11 ms |
30040 KB |
Output is correct |
8 |
Correct |
12 ms |
30040 KB |
Output is correct |
9 |
Correct |
11 ms |
30296 KB |
Output is correct |
10 |
Correct |
11 ms |
30040 KB |
Output is correct |
11 |
Correct |
11 ms |
30040 KB |
Output is correct |
12 |
Correct |
12 ms |
30040 KB |
Output is correct |
13 |
Correct |
11 ms |
30040 KB |
Output is correct |
14 |
Correct |
10 ms |
30040 KB |
Output is correct |
15 |
Correct |
12 ms |
29932 KB |
Output is correct |
16 |
Correct |
12 ms |
30040 KB |
Output is correct |
17 |
Correct |
11 ms |
30040 KB |
Output is correct |
18 |
Correct |
11 ms |
30040 KB |
Output is correct |
19 |
Correct |
11 ms |
30384 KB |
Output is correct |
20 |
Correct |
13 ms |
30040 KB |
Output is correct |
21 |
Correct |
12 ms |
30040 KB |
Output is correct |
22 |
Correct |
12 ms |
30136 KB |
Output is correct |
23 |
Correct |
11 ms |
30040 KB |
Output is correct |
24 |
Correct |
11 ms |
30296 KB |
Output is correct |
25 |
Correct |
22 ms |
32600 KB |
Output is correct |
26 |
Correct |
22 ms |
32344 KB |
Output is correct |
27 |
Correct |
24 ms |
31116 KB |
Output is correct |
28 |
Correct |
21 ms |
32856 KB |
Output is correct |
29 |
Correct |
20 ms |
32344 KB |
Output is correct |
30 |
Correct |
504 ms |
106348 KB |
Output is correct |
31 |
Correct |
547 ms |
106864 KB |
Output is correct |
32 |
Correct |
606 ms |
107128 KB |
Output is correct |
33 |
Correct |
583 ms |
107632 KB |
Output is correct |
34 |
Correct |
518 ms |
107860 KB |
Output is correct |
35 |
Correct |
614 ms |
106792 KB |
Output is correct |
36 |
Correct |
392 ms |
101456 KB |
Output is correct |
37 |
Correct |
430 ms |
101456 KB |
Output is correct |
38 |
Correct |
532 ms |
101824 KB |
Output is correct |
39 |
Correct |
541 ms |
101496 KB |
Output is correct |
40 |
Correct |
512 ms |
99916 KB |
Output is correct |
41 |
Correct |
485 ms |
97528 KB |
Output is correct |
42 |
Correct |
530 ms |
105456 KB |
Output is correct |
43 |
Correct |
575 ms |
104784 KB |
Output is correct |
44 |
Correct |
555 ms |
105040 KB |
Output is correct |
45 |
Correct |
582 ms |
105296 KB |
Output is correct |
46 |
Correct |
497 ms |
104996 KB |
Output is correct |
47 |
Correct |
565 ms |
105552 KB |
Output is correct |
48 |
Correct |
562 ms |
108428 KB |
Output is correct |
49 |
Correct |
540 ms |
109440 KB |
Output is correct |
50 |
Correct |
638 ms |
108316 KB |
Output is correct |
51 |
Correct |
467 ms |
96560 KB |
Output is correct |
52 |
Correct |
516 ms |
96540 KB |
Output is correct |
53 |
Correct |
492 ms |
96332 KB |
Output is correct |
54 |
Correct |
468 ms |
96336 KB |
Output is correct |
55 |
Correct |
495 ms |
96848 KB |
Output is correct |
56 |
Correct |
507 ms |
96804 KB |
Output is correct |
57 |
Correct |
256 ms |
59848 KB |
Output is correct |
58 |
Correct |
271 ms |
59772 KB |
Output is correct |
59 |
Correct |
290 ms |
59800 KB |
Output is correct |
60 |
Correct |
272 ms |
59792 KB |
Output is correct |
61 |
Correct |
262 ms |
59800 KB |
Output is correct |
62 |
Correct |
358 ms |
110672 KB |
Output is correct |
63 |
Correct |
339 ms |
110756 KB |
Output is correct |
64 |
Correct |
418 ms |
110620 KB |
Output is correct |
65 |
Correct |
408 ms |
110784 KB |
Output is correct |
66 |
Correct |
392 ms |
110672 KB |
Output is correct |
67 |
Correct |
460 ms |
110672 KB |
Output is correct |
68 |
Correct |
354 ms |
99152 KB |
Output is correct |
69 |
Correct |
389 ms |
99152 KB |
Output is correct |
70 |
Correct |
400 ms |
99360 KB |
Output is correct |
71 |
Correct |
392 ms |
99152 KB |
Output is correct |
72 |
Correct |
355 ms |
99152 KB |
Output is correct |
73 |
Correct |
403 ms |
99152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
30040 KB |
Output is correct |
2 |
Correct |
12 ms |
30040 KB |
Output is correct |
3 |
Correct |
12 ms |
30128 KB |
Output is correct |
4 |
Correct |
12 ms |
30296 KB |
Output is correct |
5 |
Correct |
10 ms |
30040 KB |
Output is correct |
6 |
Correct |
13 ms |
30040 KB |
Output is correct |
7 |
Correct |
11 ms |
30040 KB |
Output is correct |
8 |
Correct |
12 ms |
30040 KB |
Output is correct |
9 |
Correct |
11 ms |
30296 KB |
Output is correct |
10 |
Correct |
11 ms |
30040 KB |
Output is correct |
11 |
Correct |
11 ms |
30040 KB |
Output is correct |
12 |
Correct |
12 ms |
30040 KB |
Output is correct |
13 |
Correct |
11 ms |
30040 KB |
Output is correct |
14 |
Correct |
10 ms |
30040 KB |
Output is correct |
15 |
Correct |
12 ms |
29932 KB |
Output is correct |
16 |
Correct |
12 ms |
30040 KB |
Output is correct |
17 |
Correct |
11 ms |
30040 KB |
Output is correct |
18 |
Correct |
11 ms |
30040 KB |
Output is correct |
19 |
Correct |
11 ms |
30384 KB |
Output is correct |
20 |
Correct |
13 ms |
30040 KB |
Output is correct |
21 |
Correct |
12 ms |
30040 KB |
Output is correct |
22 |
Correct |
12 ms |
30136 KB |
Output is correct |
23 |
Correct |
11 ms |
30040 KB |
Output is correct |
24 |
Correct |
11 ms |
30296 KB |
Output is correct |
25 |
Correct |
22 ms |
32600 KB |
Output is correct |
26 |
Correct |
22 ms |
32344 KB |
Output is correct |
27 |
Correct |
24 ms |
31116 KB |
Output is correct |
28 |
Correct |
21 ms |
32856 KB |
Output is correct |
29 |
Correct |
20 ms |
32344 KB |
Output is correct |
30 |
Correct |
11 ms |
30040 KB |
Output is correct |
31 |
Correct |
810 ms |
190484 KB |
Output is correct |
32 |
Correct |
834 ms |
189808 KB |
Output is correct |
33 |
Correct |
738 ms |
188076 KB |
Output is correct |
34 |
Correct |
856 ms |
190800 KB |
Output is correct |
35 |
Correct |
308 ms |
178000 KB |
Output is correct |
36 |
Correct |
308 ms |
178000 KB |
Output is correct |
37 |
Correct |
657 ms |
179004 KB |
Output is correct |
38 |
Correct |
684 ms |
178072 KB |
Output is correct |
39 |
Correct |
656 ms |
175268 KB |
Output is correct |
40 |
Correct |
667 ms |
170152 KB |
Output is correct |
41 |
Correct |
743 ms |
186192 KB |
Output is correct |
42 |
Correct |
781 ms |
186276 KB |
Output is correct |
43 |
Correct |
656 ms |
185972 KB |
Output is correct |
44 |
Correct |
783 ms |
185424 KB |
Output is correct |
45 |
Correct |
818 ms |
194128 KB |
Output is correct |
46 |
Correct |
12 ms |
30040 KB |
Output is correct |
47 |
Correct |
12 ms |
30040 KB |
Output is correct |
48 |
Correct |
12 ms |
29928 KB |
Output is correct |
49 |
Correct |
11 ms |
30040 KB |
Output is correct |
50 |
Correct |
664 ms |
165312 KB |
Output is correct |
51 |
Correct |
687 ms |
165288 KB |
Output is correct |
52 |
Correct |
577 ms |
166224 KB |
Output is correct |
53 |
Correct |
660 ms |
167248 KB |
Output is correct |
54 |
Correct |
260 ms |
89628 KB |
Output is correct |
55 |
Correct |
248 ms |
89540 KB |
Output is correct |
56 |
Correct |
287 ms |
89604 KB |
Output is correct |
57 |
Correct |
254 ms |
89624 KB |
Output is correct |
58 |
Correct |
373 ms |
196688 KB |
Output is correct |
59 |
Correct |
400 ms |
196944 KB |
Output is correct |
60 |
Correct |
330 ms |
196760 KB |
Output is correct |
61 |
Correct |
413 ms |
196836 KB |
Output is correct |
62 |
Correct |
357 ms |
174520 KB |
Output is correct |
63 |
Correct |
364 ms |
174416 KB |
Output is correct |
64 |
Correct |
315 ms |
174512 KB |
Output is correct |
65 |
Correct |
361 ms |
174416 KB |
Output is correct |
66 |
Correct |
12 ms |
30040 KB |
Output is correct |
67 |
Correct |
11 ms |
30040 KB |
Output is correct |
68 |
Correct |
13 ms |
30108 KB |
Output is correct |
69 |
Correct |
11 ms |
30040 KB |
Output is correct |
70 |
Correct |
12 ms |
30040 KB |
Output is correct |
71 |
Correct |
14 ms |
30040 KB |
Output is correct |
72 |
Correct |
12 ms |
30296 KB |
Output is correct |
73 |
Correct |
21 ms |
32856 KB |
Output is correct |
74 |
Correct |
377 ms |
196776 KB |
Output is correct |
75 |
Correct |
362 ms |
196780 KB |
Output is correct |
76 |
Correct |
322 ms |
196944 KB |
Output is correct |
77 |
Correct |
362 ms |
196788 KB |
Output is correct |
78 |
Correct |
336 ms |
110784 KB |
Output is correct |
79 |
Correct |
336 ms |
110648 KB |
Output is correct |
80 |
Correct |
422 ms |
110676 KB |
Output is correct |
81 |
Correct |
415 ms |
110708 KB |
Output is correct |
82 |
Correct |
382 ms |
110620 KB |
Output is correct |
83 |
Correct |
421 ms |
111008 KB |
Output is correct |
84 |
Correct |
758 ms |
196944 KB |
Output is correct |
85 |
Correct |
715 ms |
196944 KB |
Output is correct |
86 |
Correct |
948 ms |
196792 KB |
Output is correct |
87 |
Correct |
983 ms |
197036 KB |
Output is correct |
88 |
Correct |
866 ms |
196760 KB |
Output is correct |
89 |
Correct |
945 ms |
196944 KB |
Output is correct |
90 |
Correct |
10 ms |
30040 KB |
Output is correct |
91 |
Correct |
11 ms |
30040 KB |
Output is correct |
92 |
Correct |
11 ms |
30040 KB |
Output is correct |
93 |
Correct |
11 ms |
30040 KB |
Output is correct |
94 |
Correct |
10 ms |
30040 KB |
Output is correct |
95 |
Correct |
12 ms |
30296 KB |
Output is correct |
96 |
Correct |
21 ms |
32344 KB |
Output is correct |
97 |
Correct |
331 ms |
174464 KB |
Output is correct |
98 |
Correct |
358 ms |
174520 KB |
Output is correct |
99 |
Correct |
308 ms |
174416 KB |
Output is correct |
100 |
Correct |
339 ms |
174500 KB |
Output is correct |
101 |
Correct |
320 ms |
99152 KB |
Output is correct |
102 |
Correct |
410 ms |
99152 KB |
Output is correct |
103 |
Correct |
408 ms |
99240 KB |
Output is correct |
104 |
Correct |
405 ms |
99328 KB |
Output is correct |
105 |
Correct |
374 ms |
99152 KB |
Output is correct |
106 |
Correct |
423 ms |
99300 KB |
Output is correct |
107 |
Correct |
750 ms |
174416 KB |
Output is correct |
108 |
Correct |
920 ms |
174420 KB |
Output is correct |
109 |
Correct |
888 ms |
174416 KB |
Output is correct |
110 |
Correct |
876 ms |
174552 KB |
Output is correct |
111 |
Correct |
780 ms |
174416 KB |
Output is correct |
112 |
Correct |
879 ms |
174500 KB |
Output is correct |
113 |
Correct |
504 ms |
106348 KB |
Output is correct |
114 |
Correct |
547 ms |
106864 KB |
Output is correct |
115 |
Correct |
606 ms |
107128 KB |
Output is correct |
116 |
Correct |
583 ms |
107632 KB |
Output is correct |
117 |
Correct |
518 ms |
107860 KB |
Output is correct |
118 |
Correct |
614 ms |
106792 KB |
Output is correct |
119 |
Correct |
392 ms |
101456 KB |
Output is correct |
120 |
Correct |
430 ms |
101456 KB |
Output is correct |
121 |
Correct |
532 ms |
101824 KB |
Output is correct |
122 |
Correct |
541 ms |
101496 KB |
Output is correct |
123 |
Correct |
512 ms |
99916 KB |
Output is correct |
124 |
Correct |
485 ms |
97528 KB |
Output is correct |
125 |
Correct |
530 ms |
105456 KB |
Output is correct |
126 |
Correct |
575 ms |
104784 KB |
Output is correct |
127 |
Correct |
555 ms |
105040 KB |
Output is correct |
128 |
Correct |
582 ms |
105296 KB |
Output is correct |
129 |
Correct |
497 ms |
104996 KB |
Output is correct |
130 |
Correct |
565 ms |
105552 KB |
Output is correct |
131 |
Correct |
562 ms |
108428 KB |
Output is correct |
132 |
Correct |
540 ms |
109440 KB |
Output is correct |
133 |
Correct |
638 ms |
108316 KB |
Output is correct |
134 |
Correct |
467 ms |
96560 KB |
Output is correct |
135 |
Correct |
516 ms |
96540 KB |
Output is correct |
136 |
Correct |
492 ms |
96332 KB |
Output is correct |
137 |
Correct |
468 ms |
96336 KB |
Output is correct |
138 |
Correct |
495 ms |
96848 KB |
Output is correct |
139 |
Correct |
507 ms |
96804 KB |
Output is correct |
140 |
Correct |
256 ms |
59848 KB |
Output is correct |
141 |
Correct |
271 ms |
59772 KB |
Output is correct |
142 |
Correct |
290 ms |
59800 KB |
Output is correct |
143 |
Correct |
272 ms |
59792 KB |
Output is correct |
144 |
Correct |
262 ms |
59800 KB |
Output is correct |
145 |
Correct |
358 ms |
110672 KB |
Output is correct |
146 |
Correct |
339 ms |
110756 KB |
Output is correct |
147 |
Correct |
418 ms |
110620 KB |
Output is correct |
148 |
Correct |
408 ms |
110784 KB |
Output is correct |
149 |
Correct |
392 ms |
110672 KB |
Output is correct |
150 |
Correct |
460 ms |
110672 KB |
Output is correct |
151 |
Correct |
354 ms |
99152 KB |
Output is correct |
152 |
Correct |
389 ms |
99152 KB |
Output is correct |
153 |
Correct |
400 ms |
99360 KB |
Output is correct |
154 |
Correct |
392 ms |
99152 KB |
Output is correct |
155 |
Correct |
355 ms |
99152 KB |
Output is correct |
156 |
Correct |
403 ms |
99152 KB |
Output is correct |
157 |
Correct |
1175 ms |
189372 KB |
Output is correct |
158 |
Correct |
1215 ms |
190032 KB |
Output is correct |
159 |
Correct |
1397 ms |
188788 KB |
Output is correct |
160 |
Correct |
1411 ms |
188072 KB |
Output is correct |
161 |
Correct |
1270 ms |
190800 KB |
Output is correct |
162 |
Correct |
1448 ms |
190324 KB |
Output is correct |
163 |
Correct |
874 ms |
178028 KB |
Output is correct |
164 |
Correct |
883 ms |
178020 KB |
Output is correct |
165 |
Correct |
1279 ms |
179004 KB |
Output is correct |
166 |
Correct |
1293 ms |
178320 KB |
Output is correct |
167 |
Correct |
1232 ms |
175276 KB |
Output is correct |
168 |
Correct |
1213 ms |
170060 KB |
Output is correct |
169 |
Correct |
1093 ms |
185856 KB |
Output is correct |
170 |
Correct |
1333 ms |
185168 KB |
Output is correct |
171 |
Correct |
1301 ms |
185304 KB |
Output is correct |
172 |
Correct |
1346 ms |
185168 KB |
Output is correct |
173 |
Correct |
1168 ms |
185704 KB |
Output is correct |
174 |
Correct |
1316 ms |
186196 KB |
Output is correct |
175 |
Correct |
1210 ms |
192204 KB |
Output is correct |
176 |
Correct |
1211 ms |
193536 KB |
Output is correct |
177 |
Correct |
1389 ms |
196260 KB |
Output is correct |
178 |
Correct |
1000 ms |
166776 KB |
Output is correct |
179 |
Correct |
1144 ms |
166572 KB |
Output is correct |
180 |
Correct |
1244 ms |
169552 KB |
Output is correct |
181 |
Correct |
1078 ms |
164520 KB |
Output is correct |
182 |
Correct |
1243 ms |
166820 KB |
Output is correct |
183 |
Correct |
1196 ms |
164776 KB |
Output is correct |
184 |
Correct |
547 ms |
89540 KB |
Output is correct |
185 |
Correct |
619 ms |
89624 KB |
Output is correct |
186 |
Correct |
578 ms |
89624 KB |
Output is correct |
187 |
Correct |
610 ms |
89540 KB |
Output is correct |
188 |
Correct |
579 ms |
89584 KB |
Output is correct |