Submission #591911

# Submission time Handle Problem Language Result Execution time Memory
591911 2022-07-08T08:34:19 Z Lucpp Fountain Parks (IOI21_parks) C++17
100 / 100
434 ms 42076 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> par;
int find(int i){
    if(i == par[i]) return i;
    else return par[i] = find(par[i]);
}
bool merge(int a, int b){
    a = find(a), b = find(b);
    if(a == b) return false; 
    par[a] = b;
    return true;
}

pair<int, int> getBench(int x1, int y1, int x2, int y2){
    if(x1 == x2){
        pair<int, int> a = {x1+1, (y1+y2)/2}, b = {x1-1, (y1+y2)/2};
        if((a.first + a.second) % 4 == 0) return a;
        else return b;
    }
    else{
        pair<int, int> a = {(x1+x2)/2, y1+1}, b = {(x1+x2)/2, y1-1};
        if((a.first + a.second) % 4 == 2) return a;
        else return b;
    }
}

int construct_roads(vector<int> vx, vector<int> vy) {
    if (vx.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    int n = (int)vx.size();
    par.resize(n);
    for(int i = 0; i < n; i++) par[i] = i;
    vector<tuple<int, int, int>> p;
    map<pair<int, int>, int> mp;
    for(int i = 0; i < n; i++){
        p.emplace_back(vx[i], vy[i], i);
        mp[make_pair(vx[i], vy[i])] = i;
    }
    int sz = 0;
    set<pair<int, int>> benches;
    sort(p.begin(), p.end());
    vector<int> dx = {-2, 0}, dy = {0, -2};
    vector<int> u, v, a, b;
    for(auto [x, y, i] : p){
        for(int j = 0; j < 2; j++){
            int x2 = x+dx[j], y2 = y+dy[j];
            if(!mp.count(make_pair(x2, y2))) continue;
            int k = mp[make_pair(x2, y2)];
            auto bench = getBench(x, y, x2, y2);
            if(benches.count(bench)) continue;
            if(merge(i, k)){
                sz++;
                u.push_back(i);
                v.push_back(k);
                a.push_back(bench.first);
                b.push_back(bench.second);
                benches.insert(bench);
            }
        }
    }
    if(sz != n-1) return 0;
    build(u, v, a, b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 152 ms 20044 KB Output is correct
10 Correct 15 ms 2268 KB Output is correct
11 Correct 71 ms 10892 KB Output is correct
12 Correct 17 ms 3232 KB Output is correct
13 Correct 43 ms 7632 KB Output is correct
14 Correct 1 ms 428 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 156 ms 20092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 152 ms 20044 KB Output is correct
10 Correct 15 ms 2268 KB Output is correct
11 Correct 71 ms 10892 KB Output is correct
12 Correct 17 ms 3232 KB Output is correct
13 Correct 43 ms 7632 KB Output is correct
14 Correct 1 ms 428 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 156 ms 20092 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 388 ms 40120 KB Output is correct
24 Correct 0 ms 296 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 728 KB Output is correct
27 Correct 4 ms 852 KB Output is correct
28 Correct 130 ms 16116 KB Output is correct
29 Correct 222 ms 24148 KB Output is correct
30 Correct 324 ms 32356 KB Output is correct
31 Correct 398 ms 40144 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 154 ms 20088 KB Output is correct
46 Correct 252 ms 29792 KB Output is correct
47 Correct 253 ms 29844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 152 ms 20044 KB Output is correct
10 Correct 15 ms 2268 KB Output is correct
11 Correct 71 ms 10892 KB Output is correct
12 Correct 17 ms 3232 KB Output is correct
13 Correct 43 ms 7632 KB Output is correct
14 Correct 1 ms 428 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 156 ms 20092 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 388 ms 40120 KB Output is correct
24 Correct 0 ms 296 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 728 KB Output is correct
27 Correct 4 ms 852 KB Output is correct
28 Correct 130 ms 16116 KB Output is correct
29 Correct 222 ms 24148 KB Output is correct
30 Correct 324 ms 32356 KB Output is correct
31 Correct 398 ms 40144 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 154 ms 20088 KB Output is correct
46 Correct 252 ms 29792 KB Output is correct
47 Correct 253 ms 29844 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 0 ms 296 KB Output is correct
53 Correct 1 ms 304 KB Output is correct
54 Correct 0 ms 300 KB Output is correct
55 Correct 406 ms 39944 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 2 ms 596 KB Output is correct
58 Correct 10 ms 1584 KB Output is correct
59 Correct 10 ms 1876 KB Output is correct
60 Correct 171 ms 20032 KB Output is correct
61 Correct 236 ms 28116 KB Output is correct
62 Correct 305 ms 33528 KB Output is correct
63 Correct 410 ms 40104 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 296 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 422 ms 40160 KB Output is correct
68 Correct 406 ms 40136 KB Output is correct
69 Correct 398 ms 39996 KB Output is correct
70 Correct 4 ms 852 KB Output is correct
71 Correct 12 ms 1620 KB Output is correct
72 Correct 158 ms 20008 KB Output is correct
73 Correct 251 ms 30524 KB Output is correct
74 Correct 410 ms 40212 KB Output is correct
75 Correct 421 ms 40100 KB Output is correct
76 Correct 409 ms 40100 KB Output is correct
77 Correct 5 ms 1108 KB Output is correct
78 Correct 11 ms 1748 KB Output is correct
79 Correct 167 ms 19980 KB Output is correct
80 Correct 277 ms 30560 KB Output is correct
81 Correct 377 ms 40196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 152 ms 20044 KB Output is correct
10 Correct 15 ms 2268 KB Output is correct
11 Correct 71 ms 10892 KB Output is correct
12 Correct 17 ms 3232 KB Output is correct
13 Correct 43 ms 7632 KB Output is correct
14 Correct 1 ms 428 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 156 ms 20092 KB Output is correct
17 Correct 1 ms 292 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 393 ms 41896 KB Output is correct
21 Correct 422 ms 41476 KB Output is correct
22 Correct 388 ms 41432 KB Output is correct
23 Correct 321 ms 34992 KB Output is correct
24 Correct 206 ms 20724 KB Output is correct
25 Correct 336 ms 33356 KB Output is correct
26 Correct 275 ms 33332 KB Output is correct
27 Correct 365 ms 39980 KB Output is correct
28 Correct 358 ms 40044 KB Output is correct
29 Correct 388 ms 39948 KB Output is correct
30 Correct 377 ms 40000 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 20 ms 3248 KB Output is correct
33 Correct 92 ms 10848 KB Output is correct
34 Correct 388 ms 41896 KB Output is correct
35 Correct 11 ms 1948 KB Output is correct
36 Correct 65 ms 8804 KB Output is correct
37 Correct 146 ms 17348 KB Output is correct
38 Correct 133 ms 17140 KB Output is correct
39 Correct 188 ms 23008 KB Output is correct
40 Correct 256 ms 30320 KB Output is correct
41 Correct 326 ms 35808 KB Output is correct
42 Correct 388 ms 41896 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 300 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 296 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 300 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 3 ms 596 KB Output is correct
55 Correct 3 ms 724 KB Output is correct
56 Correct 168 ms 20168 KB Output is correct
57 Correct 256 ms 29860 KB Output is correct
58 Correct 241 ms 29708 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 0 ms 300 KB Output is correct
61 Correct 0 ms 212 KB Output is correct
62 Correct 354 ms 40060 KB Output is correct
63 Correct 364 ms 40064 KB Output is correct
64 Correct 369 ms 39972 KB Output is correct
65 Correct 4 ms 852 KB Output is correct
66 Correct 8 ms 1504 KB Output is correct
67 Correct 152 ms 19972 KB Output is correct
68 Correct 259 ms 30548 KB Output is correct
69 Correct 378 ms 40104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 152 ms 20044 KB Output is correct
10 Correct 15 ms 2268 KB Output is correct
11 Correct 71 ms 10892 KB Output is correct
12 Correct 17 ms 3232 KB Output is correct
13 Correct 43 ms 7632 KB Output is correct
14 Correct 1 ms 428 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 156 ms 20092 KB Output is correct
17 Correct 358 ms 40848 KB Output is correct
18 Correct 401 ms 41136 KB Output is correct
19 Correct 386 ms 41492 KB Output is correct
20 Correct 381 ms 39100 KB Output is correct
21 Correct 301 ms 35356 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 45 ms 6816 KB Output is correct
24 Correct 23 ms 3696 KB Output is correct
25 Correct 110 ms 12620 KB Output is correct
26 Correct 169 ms 20724 KB Output is correct
27 Correct 157 ms 20916 KB Output is correct
28 Correct 212 ms 26376 KB Output is correct
29 Correct 278 ms 32136 KB Output is correct
30 Correct 325 ms 36448 KB Output is correct
31 Correct 376 ms 42076 KB Output is correct
32 Correct 401 ms 40208 KB Output is correct
33 Correct 377 ms 40224 KB Output is correct
34 Correct 5 ms 1108 KB Output is correct
35 Correct 9 ms 1848 KB Output is correct
36 Correct 160 ms 19964 KB Output is correct
37 Correct 272 ms 30548 KB Output is correct
38 Correct 434 ms 40500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 152 ms 20044 KB Output is correct
10 Correct 15 ms 2268 KB Output is correct
11 Correct 71 ms 10892 KB Output is correct
12 Correct 17 ms 3232 KB Output is correct
13 Correct 43 ms 7632 KB Output is correct
14 Correct 1 ms 428 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 156 ms 20092 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 388 ms 40120 KB Output is correct
24 Correct 0 ms 296 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 728 KB Output is correct
27 Correct 4 ms 852 KB Output is correct
28 Correct 130 ms 16116 KB Output is correct
29 Correct 222 ms 24148 KB Output is correct
30 Correct 324 ms 32356 KB Output is correct
31 Correct 398 ms 40144 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 154 ms 20088 KB Output is correct
46 Correct 252 ms 29792 KB Output is correct
47 Correct 253 ms 29844 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 0 ms 296 KB Output is correct
53 Correct 1 ms 304 KB Output is correct
54 Correct 0 ms 300 KB Output is correct
55 Correct 406 ms 39944 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 2 ms 596 KB Output is correct
58 Correct 10 ms 1584 KB Output is correct
59 Correct 10 ms 1876 KB Output is correct
60 Correct 171 ms 20032 KB Output is correct
61 Correct 236 ms 28116 KB Output is correct
62 Correct 305 ms 33528 KB Output is correct
63 Correct 410 ms 40104 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 296 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 422 ms 40160 KB Output is correct
68 Correct 406 ms 40136 KB Output is correct
69 Correct 398 ms 39996 KB Output is correct
70 Correct 4 ms 852 KB Output is correct
71 Correct 12 ms 1620 KB Output is correct
72 Correct 158 ms 20008 KB Output is correct
73 Correct 251 ms 30524 KB Output is correct
74 Correct 410 ms 40212 KB Output is correct
75 Correct 421 ms 40100 KB Output is correct
76 Correct 409 ms 40100 KB Output is correct
77 Correct 5 ms 1108 KB Output is correct
78 Correct 11 ms 1748 KB Output is correct
79 Correct 167 ms 19980 KB Output is correct
80 Correct 277 ms 30560 KB Output is correct
81 Correct 377 ms 40196 KB Output is correct
82 Correct 1 ms 292 KB Output is correct
83 Correct 0 ms 212 KB Output is correct
84 Correct 1 ms 296 KB Output is correct
85 Correct 393 ms 41896 KB Output is correct
86 Correct 422 ms 41476 KB Output is correct
87 Correct 388 ms 41432 KB Output is correct
88 Correct 321 ms 34992 KB Output is correct
89 Correct 206 ms 20724 KB Output is correct
90 Correct 336 ms 33356 KB Output is correct
91 Correct 275 ms 33332 KB Output is correct
92 Correct 365 ms 39980 KB Output is correct
93 Correct 358 ms 40044 KB Output is correct
94 Correct 388 ms 39948 KB Output is correct
95 Correct 377 ms 40000 KB Output is correct
96 Correct 1 ms 212 KB Output is correct
97 Correct 20 ms 3248 KB Output is correct
98 Correct 92 ms 10848 KB Output is correct
99 Correct 388 ms 41896 KB Output is correct
100 Correct 11 ms 1948 KB Output is correct
101 Correct 65 ms 8804 KB Output is correct
102 Correct 146 ms 17348 KB Output is correct
103 Correct 133 ms 17140 KB Output is correct
104 Correct 188 ms 23008 KB Output is correct
105 Correct 256 ms 30320 KB Output is correct
106 Correct 326 ms 35808 KB Output is correct
107 Correct 388 ms 41896 KB Output is correct
108 Correct 0 ms 212 KB Output is correct
109 Correct 1 ms 212 KB Output is correct
110 Correct 0 ms 212 KB Output is correct
111 Correct 1 ms 300 KB Output is correct
112 Correct 1 ms 212 KB Output is correct
113 Correct 1 ms 296 KB Output is correct
114 Correct 1 ms 212 KB Output is correct
115 Correct 1 ms 212 KB Output is correct
116 Correct 0 ms 212 KB Output is correct
117 Correct 1 ms 300 KB Output is correct
118 Correct 1 ms 212 KB Output is correct
119 Correct 3 ms 596 KB Output is correct
120 Correct 3 ms 724 KB Output is correct
121 Correct 168 ms 20168 KB Output is correct
122 Correct 256 ms 29860 KB Output is correct
123 Correct 241 ms 29708 KB Output is correct
124 Correct 0 ms 212 KB Output is correct
125 Correct 0 ms 300 KB Output is correct
126 Correct 0 ms 212 KB Output is correct
127 Correct 354 ms 40060 KB Output is correct
128 Correct 364 ms 40064 KB Output is correct
129 Correct 369 ms 39972 KB Output is correct
130 Correct 4 ms 852 KB Output is correct
131 Correct 8 ms 1504 KB Output is correct
132 Correct 152 ms 19972 KB Output is correct
133 Correct 259 ms 30548 KB Output is correct
134 Correct 378 ms 40104 KB Output is correct
135 Correct 358 ms 40848 KB Output is correct
136 Correct 401 ms 41136 KB Output is correct
137 Correct 386 ms 41492 KB Output is correct
138 Correct 381 ms 39100 KB Output is correct
139 Correct 301 ms 35356 KB Output is correct
140 Correct 0 ms 212 KB Output is correct
141 Correct 45 ms 6816 KB Output is correct
142 Correct 23 ms 3696 KB Output is correct
143 Correct 110 ms 12620 KB Output is correct
144 Correct 169 ms 20724 KB Output is correct
145 Correct 157 ms 20916 KB Output is correct
146 Correct 212 ms 26376 KB Output is correct
147 Correct 278 ms 32136 KB Output is correct
148 Correct 325 ms 36448 KB Output is correct
149 Correct 376 ms 42076 KB Output is correct
150 Correct 401 ms 40208 KB Output is correct
151 Correct 377 ms 40224 KB Output is correct
152 Correct 5 ms 1108 KB Output is correct
153 Correct 9 ms 1848 KB Output is correct
154 Correct 160 ms 19964 KB Output is correct
155 Correct 272 ms 30548 KB Output is correct
156 Correct 434 ms 40500 KB Output is correct
157 Correct 1 ms 212 KB Output is correct
158 Correct 0 ms 212 KB Output is correct
159 Correct 0 ms 212 KB Output is correct
160 Correct 1 ms 212 KB Output is correct
161 Correct 387 ms 40800 KB Output is correct
162 Correct 414 ms 41988 KB Output is correct
163 Correct 387 ms 41608 KB Output is correct
164 Correct 374 ms 41592 KB Output is correct
165 Correct 377 ms 41332 KB Output is correct
166 Correct 370 ms 40772 KB Output is correct
167 Correct 77 ms 9888 KB Output is correct
168 Correct 34 ms 5384 KB Output is correct
169 Correct 102 ms 13956 KB Output is correct
170 Correct 248 ms 26192 KB Output is correct
171 Correct 313 ms 34276 KB Output is correct
172 Correct 168 ms 21000 KB Output is correct
173 Correct 228 ms 25028 KB Output is correct
174 Correct 243 ms 30248 KB Output is correct
175 Correct 286 ms 33416 KB Output is correct
176 Correct 344 ms 37816 KB Output is correct
177 Correct 391 ms 41888 KB Output is correct