#include <iostream> // std::cout
#include <algorithm> // std::sort
#include <vector> // std::vector
#include "parks.h"
using namespace std;
vector<int> x, y;
vector<int> north, south, east, west;
vector<int> visited;
bool cmpx(int i, int j) {
if (x[i] == x[j])
return (y[i] < y[j]);
return (x[i] < x[j]);
}
bool cmpy(int i, int j) {
if (y[i] == y[j])
return (x[i] < x[j]);
return (y[i] < y[j]);
}
bool cmpsum(int i, int j) {
return (x[i]+y[i] > x[j] + y[j]);
}
// Disjoint set union
vector <int> parent;
void make_set(int v) {
parent[v] = v;
}
int find_set(int v) {
if (v == parent[v])
return v;
return find_set(parent[v]);
}
void union_sets(int a, int b) {
a = find_set(a);
b = find_set(b);
if (a != b)
parent[b] = a;
}
void RunDFS(int s) {
vector<int> stack;
// cout << s << visited[s] << " north: " << north[s] << " east: " << east[s] << " south: " << south[s] << " west: " << west[s] << endl;
stack.push_back(s);
while (stack.size() > 0) {
int t = stack.back();
stack.pop_back();
if (visited[t] != 1) {
visited[t]=1;
if(north[t] != -1) stack.push_back(north[t]);
if(west[t] != -1) stack.push_back(west[t]);
if(south[t] != -1) stack.push_back(south[t]);
if(east[t] != -1) stack.push_back(east[t]);
}
}
}
/*
void RunDFS(int s) {
if(visited[s] == 1) return;
visited[s]=1;
if(north[s] != -1) RunDFS(north[s]);
if(west[s] != -1) RunDFS(west[s]);
if(south[s] != -1) RunDFS(south[s]);
if(east[s] != -1) RunDFS(east[s]);
}
*/
// Edge set and tree set
std::vector<int> u, v, a, b;
void add_edge(int i, int j) {
u.push_back(i);
v.push_back(j);
union_sets(i, j);
// cout << "merge " << i << "," << j << endl;
if (((x[i]+y[i])/2) % 2 == 0) {
// insert tree on left
if (x[i] == x[j]) {
b.push_back( (y[i]+y[j])/2 );
if (y[j] > y[i]) {
a.push_back(x[i]-1);
} else {
a.push_back(x[i]+1);
}
} else {
a.push_back( (x[i]+x[j])/2 );
if (x[j] > x[i]) {
b.push_back(y[i]+1);
} else {
b.push_back(y[i]-1);
}
}
} else {
// insert tree on right
if (x[i] == x[j]) {
b.push_back( (y[i]+y[j])/2 );
if (y[j] > y[i]) {
a.push_back(x[i]+1);
} else {
a.push_back(x[i]-1);
}
} else {
a.push_back( (x[i]+x[j])/2 );
if (x[j] > x[i]) {
b.push_back(y[i]-1);
} else {
b.push_back(y[i]+1);
}
}
}
}
/*
void build(std::vector<int> u, std::vector<int> v, std::vector<int> a, std::vector<int> b) {
return 0;
}
*/
int construct_roads(std::vector<int> _x, std::vector<int> _y) {
x = _x;
y = _y;
std::vector<int> idx;
int n = x.size();
for(int i=0; i<n; i++) {
idx.push_back( i );
}
/*
cout << "The vector before applying sort is:\n" ;
for (int i=0; i<n; i++) {
cout << idx[i] << ": " << x[idx[i]] << " " << y[idx[i]] << endl;
}
*/
for (int i=0; i<n; i++) {
north.push_back(-1);
south.push_back(-1);
east.push_back(-1);
west.push_back(-1);
}
// Assign north & south
std::sort(idx.begin(), idx.end(), cmpx);
for (int i=0; i<n-1; i++) {
if (x[idx[i]]==x[idx[i+1]] && y[idx[i]]+2 == y[idx[i+1]]) {
north[idx[i]] = idx[i+1];
south[idx[i+1]] = idx[i];
}
}
// Assign east & west
std::sort(idx.begin(), idx.end(), cmpy);
for (int i=0; i<n-1; i++) {
if (y[idx[i]]==y[idx[i+1]] && x[idx[i]]+2 == x[idx[i+1]]) {
east[idx[i]] = idx[i+1];
west[idx[i+1]] = idx[i];
}
}
// cout << "Finish assigning directions\n";
for(int i=0; i<n; i++) {
visited.push_back(-1);
}
RunDFS(0);
bool connected = true;
for(int i=0; i<n; i++) {
if (visited[i] == -1) {
connected = false;
break;
}
}
if (connected == false) {
// cout << "It is not connected" << endl;
return 0;
}
// cout << "It is connected" << endl;
// Initialize the disjoint set
for(int i=0; i<n; i++) {
parent.push_back( i );
}
std::sort(idx.begin(), idx.end(), cmpsum);
/*
cout << "The vector after applying sort is:\n" ;
for (int i=0; i<n; i++) {
cout << idx[i] << ": north: " << north[idx[i]] << " south: " << south[idx[i]] << " east: " << east[idx[i]] << " west: " << west[idx[i]] << endl;
}
*/
for (int i=0; i<n; i++) {
// cout << idx[i] << ": north: " << north[idx[i]] << " south: " << south[idx[i]] << " east: " << east[idx[i]] << " west: " << west[idx[i]] << endl;
if (east[idx[i]] == -1 && north[idx[i]] == -1) {
// cout << "No east and north!" << endl;
continue;
} else if (east[idx[i]] != -1 && north[idx[i]] == -1) {
// Only east is neighbor
// cout << east[idx[i]] << "East only!" << endl;
add_edge(idx[i], east[idx[i]]);
continue;
} else if (east[idx[i]] == -1 && north[idx[i]] != -1) {
// Only north is neighbor
// cout << north[idx[i]] << "North only!" << endl;
add_edge(idx[i], north[idx[i]]);
continue;
}
// Both east and north are neighbors
if (find_set(east[idx[i]]) == find_set(north[idx[i]])) {
// cout << east[idx[i]] << "," << north[idx[i]] << "Each and North in the same component!" << endl;
// east and north are in the same component. So, they are connected.
if ( ((x[idx[i]]+y[idx[i]])/2) % 2 == 0 )
add_edge(idx[i], north[idx[i]]);
else
add_edge(idx[i], east[idx[i]]);
} else {
// cout << east[idx[i]] << "," << north[idx[i]] << "Each and North in different component!" << endl;
// east and north are in different component. So, they are not connected.
add_edge(idx[i], east[idx[i]]);
add_edge(idx[i], north[idx[i]]);
}
}
build(u, v, a, b);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
109 ms |
10660 KB |
Output is correct |
10 |
Correct |
8 ms |
1640 KB |
Output is correct |
11 |
Correct |
53 ms |
5692 KB |
Output is correct |
12 |
Correct |
14 ms |
2144 KB |
Output is correct |
13 |
Correct |
20 ms |
2864 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
136 ms |
10660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
109 ms |
10660 KB |
Output is correct |
10 |
Correct |
8 ms |
1640 KB |
Output is correct |
11 |
Correct |
53 ms |
5692 KB |
Output is correct |
12 |
Correct |
14 ms |
2144 KB |
Output is correct |
13 |
Correct |
20 ms |
2864 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
136 ms |
10660 KB |
Output is correct |
17 |
Correct |
1 ms |
224 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
216 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
349 ms |
23328 KB |
Output is correct |
24 |
Correct |
2 ms |
204 KB |
Output is correct |
25 |
Correct |
4 ms |
460 KB |
Output is correct |
26 |
Correct |
3 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
460 KB |
Output is correct |
28 |
Correct |
108 ms |
9748 KB |
Output is correct |
29 |
Correct |
158 ms |
13604 KB |
Output is correct |
30 |
Correct |
244 ms |
17328 KB |
Output is correct |
31 |
Correct |
273 ms |
23308 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
2 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
2 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
2 ms |
460 KB |
Output is correct |
45 |
Correct |
125 ms |
11736 KB |
Output is correct |
46 |
Correct |
206 ms |
15964 KB |
Output is correct |
47 |
Correct |
296 ms |
15724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
109 ms |
10660 KB |
Output is correct |
10 |
Correct |
8 ms |
1640 KB |
Output is correct |
11 |
Correct |
53 ms |
5692 KB |
Output is correct |
12 |
Correct |
14 ms |
2144 KB |
Output is correct |
13 |
Correct |
20 ms |
2864 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
136 ms |
10660 KB |
Output is correct |
17 |
Correct |
1 ms |
224 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
216 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
349 ms |
23328 KB |
Output is correct |
24 |
Correct |
2 ms |
204 KB |
Output is correct |
25 |
Correct |
4 ms |
460 KB |
Output is correct |
26 |
Correct |
3 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
460 KB |
Output is correct |
28 |
Correct |
108 ms |
9748 KB |
Output is correct |
29 |
Correct |
158 ms |
13604 KB |
Output is correct |
30 |
Correct |
244 ms |
17328 KB |
Output is correct |
31 |
Correct |
273 ms |
23308 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
2 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
2 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
2 ms |
460 KB |
Output is correct |
45 |
Correct |
125 ms |
11736 KB |
Output is correct |
46 |
Correct |
206 ms |
15964 KB |
Output is correct |
47 |
Correct |
296 ms |
15724 KB |
Output is correct |
48 |
Correct |
1 ms |
256 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
1 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
232 KB |
Output is correct |
53 |
Correct |
1 ms |
204 KB |
Output is correct |
54 |
Correct |
1 ms |
204 KB |
Output is correct |
55 |
Correct |
259 ms |
23216 KB |
Output is correct |
56 |
Correct |
1 ms |
204 KB |
Output is correct |
57 |
Correct |
2 ms |
460 KB |
Output is correct |
58 |
Correct |
6 ms |
972 KB |
Output is correct |
59 |
Correct |
7 ms |
844 KB |
Output is correct |
60 |
Correct |
136 ms |
11632 KB |
Output is correct |
61 |
Correct |
158 ms |
16896 KB |
Output is correct |
62 |
Correct |
242 ms |
20084 KB |
Output is correct |
63 |
Correct |
290 ms |
23280 KB |
Output is correct |
64 |
Correct |
1 ms |
204 KB |
Output is correct |
65 |
Correct |
1 ms |
204 KB |
Output is correct |
66 |
Correct |
1 ms |
204 KB |
Output is correct |
67 |
Correct |
288 ms |
20944 KB |
Output is correct |
68 |
Correct |
340 ms |
21028 KB |
Output is correct |
69 |
Correct |
335 ms |
20900 KB |
Output is correct |
70 |
Correct |
2 ms |
460 KB |
Output is correct |
71 |
Correct |
6 ms |
716 KB |
Output is correct |
72 |
Correct |
120 ms |
10496 KB |
Output is correct |
73 |
Correct |
205 ms |
16168 KB |
Output is correct |
74 |
Correct |
311 ms |
20908 KB |
Output is correct |
75 |
Correct |
256 ms |
20924 KB |
Output is correct |
76 |
Correct |
367 ms |
20936 KB |
Output is correct |
77 |
Correct |
6 ms |
588 KB |
Output is correct |
78 |
Correct |
12 ms |
828 KB |
Output is correct |
79 |
Correct |
138 ms |
10612 KB |
Output is correct |
80 |
Correct |
223 ms |
16444 KB |
Output is correct |
81 |
Correct |
257 ms |
20720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
109 ms |
10660 KB |
Output is correct |
10 |
Correct |
8 ms |
1640 KB |
Output is correct |
11 |
Correct |
53 ms |
5692 KB |
Output is correct |
12 |
Correct |
14 ms |
2144 KB |
Output is correct |
13 |
Correct |
20 ms |
2864 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
136 ms |
10660 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
235 ms |
21488 KB |
Output is correct |
21 |
Correct |
243 ms |
21296 KB |
Output is correct |
22 |
Correct |
287 ms |
21208 KB |
Output is correct |
23 |
Correct |
243 ms |
18304 KB |
Output is correct |
24 |
Correct |
159 ms |
11472 KB |
Output is correct |
25 |
Correct |
198 ms |
11456 KB |
Output is correct |
26 |
Correct |
132 ms |
11448 KB |
Output is correct |
27 |
Correct |
324 ms |
20920 KB |
Output is correct |
28 |
Correct |
596 ms |
21144 KB |
Output is correct |
29 |
Correct |
257 ms |
21008 KB |
Output is correct |
30 |
Correct |
595 ms |
20924 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
63 ms |
1976 KB |
Output is correct |
33 |
Correct |
64 ms |
5840 KB |
Output is correct |
34 |
Correct |
242 ms |
21464 KB |
Output is correct |
35 |
Correct |
8 ms |
840 KB |
Output is correct |
36 |
Correct |
33 ms |
3024 KB |
Output is correct |
37 |
Correct |
100 ms |
5876 KB |
Output is correct |
38 |
Correct |
104 ms |
9288 KB |
Output is correct |
39 |
Correct |
174 ms |
11592 KB |
Output is correct |
40 |
Correct |
196 ms |
15836 KB |
Output is correct |
41 |
Correct |
291 ms |
18576 KB |
Output is correct |
42 |
Correct |
376 ms |
21316 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
1 ms |
204 KB |
Output is correct |
45 |
Correct |
1 ms |
288 KB |
Output is correct |
46 |
Correct |
1 ms |
204 KB |
Output is correct |
47 |
Correct |
1 ms |
332 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
1 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
204 KB |
Output is correct |
53 |
Correct |
1 ms |
204 KB |
Output is correct |
54 |
Correct |
1 ms |
332 KB |
Output is correct |
55 |
Correct |
2 ms |
460 KB |
Output is correct |
56 |
Correct |
123 ms |
11660 KB |
Output is correct |
57 |
Correct |
174 ms |
15928 KB |
Output is correct |
58 |
Correct |
237 ms |
15620 KB |
Output is correct |
59 |
Correct |
1 ms |
204 KB |
Output is correct |
60 |
Correct |
1 ms |
204 KB |
Output is correct |
61 |
Correct |
1 ms |
204 KB |
Output is correct |
62 |
Correct |
278 ms |
20944 KB |
Output is correct |
63 |
Correct |
309 ms |
21040 KB |
Output is correct |
64 |
Correct |
292 ms |
20916 KB |
Output is correct |
65 |
Correct |
3 ms |
460 KB |
Output is correct |
66 |
Correct |
4 ms |
608 KB |
Output is correct |
67 |
Correct |
110 ms |
10540 KB |
Output is correct |
68 |
Correct |
172 ms |
16208 KB |
Output is correct |
69 |
Correct |
254 ms |
20948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
109 ms |
10660 KB |
Output is correct |
10 |
Correct |
8 ms |
1640 KB |
Output is correct |
11 |
Correct |
53 ms |
5692 KB |
Output is correct |
12 |
Correct |
14 ms |
2144 KB |
Output is correct |
13 |
Correct |
20 ms |
2864 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
136 ms |
10660 KB |
Output is correct |
17 |
Correct |
296 ms |
20812 KB |
Output is correct |
18 |
Correct |
303 ms |
20804 KB |
Output is correct |
19 |
Correct |
245 ms |
21268 KB |
Output is correct |
20 |
Correct |
858 ms |
22772 KB |
Output is correct |
21 |
Correct |
490 ms |
18640 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
42 ms |
4052 KB |
Output is correct |
24 |
Correct |
12 ms |
1484 KB |
Output is correct |
25 |
Correct |
44 ms |
4596 KB |
Output is correct |
26 |
Correct |
89 ms |
6676 KB |
Output is correct |
27 |
Correct |
250 ms |
10620 KB |
Output is correct |
28 |
Correct |
345 ms |
14788 KB |
Output is correct |
29 |
Correct |
469 ms |
17076 KB |
Output is correct |
30 |
Correct |
589 ms |
18744 KB |
Output is correct |
31 |
Correct |
711 ms |
21456 KB |
Output is correct |
32 |
Correct |
244 ms |
21020 KB |
Output is correct |
33 |
Correct |
285 ms |
21068 KB |
Output is correct |
34 |
Correct |
3 ms |
588 KB |
Output is correct |
35 |
Correct |
5 ms |
844 KB |
Output is correct |
36 |
Correct |
115 ms |
10628 KB |
Output is correct |
37 |
Correct |
213 ms |
16436 KB |
Output is correct |
38 |
Correct |
241 ms |
20688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
109 ms |
10660 KB |
Output is correct |
10 |
Correct |
8 ms |
1640 KB |
Output is correct |
11 |
Correct |
53 ms |
5692 KB |
Output is correct |
12 |
Correct |
14 ms |
2144 KB |
Output is correct |
13 |
Correct |
20 ms |
2864 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
136 ms |
10660 KB |
Output is correct |
17 |
Correct |
1 ms |
224 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
216 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
349 ms |
23328 KB |
Output is correct |
24 |
Correct |
2 ms |
204 KB |
Output is correct |
25 |
Correct |
4 ms |
460 KB |
Output is correct |
26 |
Correct |
3 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
460 KB |
Output is correct |
28 |
Correct |
108 ms |
9748 KB |
Output is correct |
29 |
Correct |
158 ms |
13604 KB |
Output is correct |
30 |
Correct |
244 ms |
17328 KB |
Output is correct |
31 |
Correct |
273 ms |
23308 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
2 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
2 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
2 ms |
460 KB |
Output is correct |
45 |
Correct |
125 ms |
11736 KB |
Output is correct |
46 |
Correct |
206 ms |
15964 KB |
Output is correct |
47 |
Correct |
296 ms |
15724 KB |
Output is correct |
48 |
Correct |
1 ms |
256 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
1 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
232 KB |
Output is correct |
53 |
Correct |
1 ms |
204 KB |
Output is correct |
54 |
Correct |
1 ms |
204 KB |
Output is correct |
55 |
Correct |
259 ms |
23216 KB |
Output is correct |
56 |
Correct |
1 ms |
204 KB |
Output is correct |
57 |
Correct |
2 ms |
460 KB |
Output is correct |
58 |
Correct |
6 ms |
972 KB |
Output is correct |
59 |
Correct |
7 ms |
844 KB |
Output is correct |
60 |
Correct |
136 ms |
11632 KB |
Output is correct |
61 |
Correct |
158 ms |
16896 KB |
Output is correct |
62 |
Correct |
242 ms |
20084 KB |
Output is correct |
63 |
Correct |
290 ms |
23280 KB |
Output is correct |
64 |
Correct |
1 ms |
204 KB |
Output is correct |
65 |
Correct |
1 ms |
204 KB |
Output is correct |
66 |
Correct |
1 ms |
204 KB |
Output is correct |
67 |
Correct |
288 ms |
20944 KB |
Output is correct |
68 |
Correct |
340 ms |
21028 KB |
Output is correct |
69 |
Correct |
335 ms |
20900 KB |
Output is correct |
70 |
Correct |
2 ms |
460 KB |
Output is correct |
71 |
Correct |
6 ms |
716 KB |
Output is correct |
72 |
Correct |
120 ms |
10496 KB |
Output is correct |
73 |
Correct |
205 ms |
16168 KB |
Output is correct |
74 |
Correct |
311 ms |
20908 KB |
Output is correct |
75 |
Correct |
256 ms |
20924 KB |
Output is correct |
76 |
Correct |
367 ms |
20936 KB |
Output is correct |
77 |
Correct |
6 ms |
588 KB |
Output is correct |
78 |
Correct |
12 ms |
828 KB |
Output is correct |
79 |
Correct |
138 ms |
10612 KB |
Output is correct |
80 |
Correct |
223 ms |
16444 KB |
Output is correct |
81 |
Correct |
257 ms |
20720 KB |
Output is correct |
82 |
Correct |
1 ms |
204 KB |
Output is correct |
83 |
Correct |
1 ms |
204 KB |
Output is correct |
84 |
Correct |
1 ms |
204 KB |
Output is correct |
85 |
Correct |
235 ms |
21488 KB |
Output is correct |
86 |
Correct |
243 ms |
21296 KB |
Output is correct |
87 |
Correct |
287 ms |
21208 KB |
Output is correct |
88 |
Correct |
243 ms |
18304 KB |
Output is correct |
89 |
Correct |
159 ms |
11472 KB |
Output is correct |
90 |
Correct |
198 ms |
11456 KB |
Output is correct |
91 |
Correct |
132 ms |
11448 KB |
Output is correct |
92 |
Correct |
324 ms |
20920 KB |
Output is correct |
93 |
Correct |
596 ms |
21144 KB |
Output is correct |
94 |
Correct |
257 ms |
21008 KB |
Output is correct |
95 |
Correct |
595 ms |
20924 KB |
Output is correct |
96 |
Correct |
1 ms |
204 KB |
Output is correct |
97 |
Correct |
63 ms |
1976 KB |
Output is correct |
98 |
Correct |
64 ms |
5840 KB |
Output is correct |
99 |
Correct |
242 ms |
21464 KB |
Output is correct |
100 |
Correct |
8 ms |
840 KB |
Output is correct |
101 |
Correct |
33 ms |
3024 KB |
Output is correct |
102 |
Correct |
100 ms |
5876 KB |
Output is correct |
103 |
Correct |
104 ms |
9288 KB |
Output is correct |
104 |
Correct |
174 ms |
11592 KB |
Output is correct |
105 |
Correct |
196 ms |
15836 KB |
Output is correct |
106 |
Correct |
291 ms |
18576 KB |
Output is correct |
107 |
Correct |
376 ms |
21316 KB |
Output is correct |
108 |
Correct |
1 ms |
204 KB |
Output is correct |
109 |
Correct |
1 ms |
204 KB |
Output is correct |
110 |
Correct |
1 ms |
288 KB |
Output is correct |
111 |
Correct |
1 ms |
204 KB |
Output is correct |
112 |
Correct |
1 ms |
332 KB |
Output is correct |
113 |
Correct |
1 ms |
204 KB |
Output is correct |
114 |
Correct |
1 ms |
204 KB |
Output is correct |
115 |
Correct |
1 ms |
204 KB |
Output is correct |
116 |
Correct |
1 ms |
204 KB |
Output is correct |
117 |
Correct |
1 ms |
204 KB |
Output is correct |
118 |
Correct |
1 ms |
204 KB |
Output is correct |
119 |
Correct |
1 ms |
332 KB |
Output is correct |
120 |
Correct |
2 ms |
460 KB |
Output is correct |
121 |
Correct |
123 ms |
11660 KB |
Output is correct |
122 |
Correct |
174 ms |
15928 KB |
Output is correct |
123 |
Correct |
237 ms |
15620 KB |
Output is correct |
124 |
Correct |
1 ms |
204 KB |
Output is correct |
125 |
Correct |
1 ms |
204 KB |
Output is correct |
126 |
Correct |
1 ms |
204 KB |
Output is correct |
127 |
Correct |
278 ms |
20944 KB |
Output is correct |
128 |
Correct |
309 ms |
21040 KB |
Output is correct |
129 |
Correct |
292 ms |
20916 KB |
Output is correct |
130 |
Correct |
3 ms |
460 KB |
Output is correct |
131 |
Correct |
4 ms |
608 KB |
Output is correct |
132 |
Correct |
110 ms |
10540 KB |
Output is correct |
133 |
Correct |
172 ms |
16208 KB |
Output is correct |
134 |
Correct |
254 ms |
20948 KB |
Output is correct |
135 |
Correct |
296 ms |
20812 KB |
Output is correct |
136 |
Correct |
303 ms |
20804 KB |
Output is correct |
137 |
Correct |
245 ms |
21268 KB |
Output is correct |
138 |
Correct |
858 ms |
22772 KB |
Output is correct |
139 |
Correct |
490 ms |
18640 KB |
Output is correct |
140 |
Correct |
1 ms |
204 KB |
Output is correct |
141 |
Correct |
42 ms |
4052 KB |
Output is correct |
142 |
Correct |
12 ms |
1484 KB |
Output is correct |
143 |
Correct |
44 ms |
4596 KB |
Output is correct |
144 |
Correct |
89 ms |
6676 KB |
Output is correct |
145 |
Correct |
250 ms |
10620 KB |
Output is correct |
146 |
Correct |
345 ms |
14788 KB |
Output is correct |
147 |
Correct |
469 ms |
17076 KB |
Output is correct |
148 |
Correct |
589 ms |
18744 KB |
Output is correct |
149 |
Correct |
711 ms |
21456 KB |
Output is correct |
150 |
Correct |
244 ms |
21020 KB |
Output is correct |
151 |
Correct |
285 ms |
21068 KB |
Output is correct |
152 |
Correct |
3 ms |
588 KB |
Output is correct |
153 |
Correct |
5 ms |
844 KB |
Output is correct |
154 |
Correct |
115 ms |
10628 KB |
Output is correct |
155 |
Correct |
213 ms |
16436 KB |
Output is correct |
156 |
Correct |
241 ms |
20688 KB |
Output is correct |
157 |
Correct |
1 ms |
204 KB |
Output is correct |
158 |
Correct |
1 ms |
204 KB |
Output is correct |
159 |
Correct |
1 ms |
204 KB |
Output is correct |
160 |
Correct |
1 ms |
204 KB |
Output is correct |
161 |
Correct |
1548 ms |
23540 KB |
Output is correct |
162 |
Correct |
277 ms |
21492 KB |
Output is correct |
163 |
Correct |
228 ms |
21956 KB |
Output is correct |
164 |
Correct |
236 ms |
21044 KB |
Output is correct |
165 |
Correct |
245 ms |
23928 KB |
Output is correct |
166 |
Correct |
290 ms |
23680 KB |
Output is correct |
167 |
Correct |
76 ms |
5764 KB |
Output is correct |
168 |
Correct |
18 ms |
1996 KB |
Output is correct |
169 |
Correct |
48 ms |
5016 KB |
Output is correct |
170 |
Correct |
97 ms |
9256 KB |
Output is correct |
171 |
Correct |
140 ms |
11472 KB |
Output is correct |
172 |
Correct |
495 ms |
12248 KB |
Output is correct |
173 |
Correct |
686 ms |
14364 KB |
Output is correct |
174 |
Correct |
858 ms |
18036 KB |
Output is correct |
175 |
Correct |
1103 ms |
19316 KB |
Output is correct |
176 |
Correct |
1338 ms |
22224 KB |
Output is correct |
177 |
Correct |
1598 ms |
24252 KB |
Output is correct |