#include "parks.h"
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define fi first
#define se second
int construct_roads(vi cordx, vi cordy){
int n=cordx.size();
vii v(n);
for (int i=0;i<n;i++) v[i]=pii{cordx[i],cordy[i]};
vi u; //ind fuentes
vi w;
vi a; // coord banco
vi b;
map<pii,int> indfuente;
for (int i=0;i<n;i++) indfuente[v[i]]=i+1;
set<pii> posiblesbancos;
for (pii p:v){
posiblesbancos.insert(pii{p.fi+1,p.se+1});
posiblesbancos.insert(pii{p.fi+1,p.se-1});
posiblesbancos.insert(pii{p.fi-1,p.se+1});
posiblesbancos.insert(pii{p.fi-1,p.se-1});
}
for (pii p:posiblesbancos){
if ((p.fi+p.se)%4==0){
if (indfuente[pii{p.fi+1,p.se+1}] && indfuente[pii{p.fi-1,p.se+1}]){
u.push_back(indfuente[pii{p.fi+1,p.se+1}]-1);
w.push_back(indfuente[pii{p.fi-1,p.se+1}]-1);
a.push_back(p.fi);
b.push_back(p.se);
}
else if (indfuente[pii{p.fi+1,p.se-1}] && indfuente[pii{p.fi-1,p.se-1}]){
u.push_back(indfuente[pii{p.fi+1,p.se-1}]-1);
w.push_back(indfuente[pii{p.fi-1,p.se-1}]-1);
a.push_back(p.fi);
b.push_back(p.se);
}
}
else{
if (indfuente[pii{p.fi+1,p.se+1}] && indfuente[pii{p.fi+1,p.se-1}]){
u.push_back(indfuente[pii{p.fi+1,p.se+1}]-1);
w.push_back(indfuente[pii{p.fi+1,p.se-1}]-1);
a.push_back(p.fi);
b.push_back(p.se);
}
else if (indfuente[pii{p.fi-1,p.se+1}] && indfuente[pii{p.fi-1,p.se-1}]){
u.push_back(indfuente[pii{p.fi-1,p.se+1}]-1);
w.push_back(indfuente[pii{p.fi-1,p.se-1}]-1);
a.push_back(p.fi);
b.push_back(p.se);
}
}
}
if (u.size()<n-1) return 0;
build(u,w,a,b);
return 1;
}
Compilation message
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:66:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
66 | if (u.size()<n-1) return 0;
| ~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
314 ms |
36288 KB |
Output is correct |
10 |
Correct |
20 ms |
4068 KB |
Output is correct |
11 |
Correct |
136 ms |
19688 KB |
Output is correct |
12 |
Correct |
30 ms |
5956 KB |
Output is correct |
13 |
Correct |
98 ms |
14740 KB |
Output is correct |
14 |
Correct |
3 ms |
588 KB |
Output is correct |
15 |
Correct |
4 ms |
844 KB |
Output is correct |
16 |
Correct |
318 ms |
36332 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 |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
314 ms |
36288 KB |
Output is correct |
10 |
Correct |
20 ms |
4068 KB |
Output is correct |
11 |
Correct |
136 ms |
19688 KB |
Output is correct |
12 |
Correct |
30 ms |
5956 KB |
Output is correct |
13 |
Correct |
98 ms |
14740 KB |
Output is correct |
14 |
Correct |
3 ms |
588 KB |
Output is correct |
15 |
Correct |
4 ms |
844 KB |
Output is correct |
16 |
Correct |
318 ms |
36332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
691 ms |
55120 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
2 ms |
588 KB |
Output is correct |
26 |
Correct |
5 ms |
976 KB |
Output is correct |
27 |
Correct |
6 ms |
1276 KB |
Output is correct |
28 |
Correct |
211 ms |
22240 KB |
Output is correct |
29 |
Correct |
329 ms |
33316 KB |
Output is correct |
30 |
Correct |
529 ms |
44232 KB |
Output is correct |
31 |
Correct |
696 ms |
55188 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
0 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
204 KB |
Output is correct |
38 |
Correct |
0 ms |
204 KB |
Output is correct |
39 |
Correct |
0 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
204 KB |
Output is correct |
42 |
Correct |
0 ms |
204 KB |
Output is correct |
43 |
Correct |
4 ms |
844 KB |
Output is correct |
44 |
Correct |
6 ms |
1228 KB |
Output is correct |
45 |
Correct |
320 ms |
34060 KB |
Output is correct |
46 |
Correct |
501 ms |
49196 KB |
Output is correct |
47 |
Correct |
510 ms |
49212 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 |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
314 ms |
36288 KB |
Output is correct |
10 |
Correct |
20 ms |
4068 KB |
Output is correct |
11 |
Correct |
136 ms |
19688 KB |
Output is correct |
12 |
Correct |
30 ms |
5956 KB |
Output is correct |
13 |
Correct |
98 ms |
14740 KB |
Output is correct |
14 |
Correct |
3 ms |
588 KB |
Output is correct |
15 |
Correct |
4 ms |
844 KB |
Output is correct |
16 |
Correct |
318 ms |
36332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
691 ms |
55120 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
2 ms |
588 KB |
Output is correct |
26 |
Correct |
5 ms |
976 KB |
Output is correct |
27 |
Correct |
6 ms |
1276 KB |
Output is correct |
28 |
Correct |
211 ms |
22240 KB |
Output is correct |
29 |
Correct |
329 ms |
33316 KB |
Output is correct |
30 |
Correct |
529 ms |
44232 KB |
Output is correct |
31 |
Correct |
696 ms |
55188 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
0 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
204 KB |
Output is correct |
38 |
Correct |
0 ms |
204 KB |
Output is correct |
39 |
Correct |
0 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
204 KB |
Output is correct |
42 |
Correct |
0 ms |
204 KB |
Output is correct |
43 |
Correct |
4 ms |
844 KB |
Output is correct |
44 |
Correct |
6 ms |
1228 KB |
Output is correct |
45 |
Correct |
320 ms |
34060 KB |
Output is correct |
46 |
Correct |
501 ms |
49196 KB |
Output is correct |
47 |
Correct |
510 ms |
49212 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
0 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
0 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
204 KB |
Output is correct |
53 |
Correct |
0 ms |
204 KB |
Output is correct |
54 |
Correct |
0 ms |
204 KB |
Output is correct |
55 |
Correct |
620 ms |
49364 KB |
Output is correct |
56 |
Correct |
1 ms |
204 KB |
Output is correct |
57 |
Correct |
3 ms |
716 KB |
Output is correct |
58 |
Correct |
10 ms |
1848 KB |
Output is correct |
59 |
Incorrect |
24 ms |
2892 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
60 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
314 ms |
36288 KB |
Output is correct |
10 |
Correct |
20 ms |
4068 KB |
Output is correct |
11 |
Correct |
136 ms |
19688 KB |
Output is correct |
12 |
Correct |
30 ms |
5956 KB |
Output is correct |
13 |
Correct |
98 ms |
14740 KB |
Output is correct |
14 |
Correct |
3 ms |
588 KB |
Output is correct |
15 |
Correct |
4 ms |
844 KB |
Output is correct |
16 |
Correct |
318 ms |
36332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
718 ms |
66920 KB |
Output is correct |
21 |
Correct |
756 ms |
66832 KB |
Output is correct |
22 |
Correct |
770 ms |
66972 KB |
Output is correct |
23 |
Correct |
602 ms |
62008 KB |
Output is correct |
24 |
Correct |
819 ms |
94400 KB |
Output is correct |
25 |
Correct |
664 ms |
53860 KB |
Output is correct |
26 |
Correct |
619 ms |
53656 KB |
Output is correct |
27 |
Correct |
684 ms |
59836 KB |
Output is correct |
28 |
Correct |
685 ms |
59924 KB |
Output is correct |
29 |
Correct |
692 ms |
59948 KB |
Output is correct |
30 |
Correct |
687 ms |
59916 KB |
Output is correct |
31 |
Correct |
0 ms |
204 KB |
Output is correct |
32 |
Correct |
37 ms |
4972 KB |
Output is correct |
33 |
Correct |
315 ms |
43008 KB |
Output is correct |
34 |
Correct |
681 ms |
60732 KB |
Output is correct |
35 |
Correct |
19 ms |
2636 KB |
Output is correct |
36 |
Correct |
117 ms |
12316 KB |
Output is correct |
37 |
Correct |
281 ms |
24424 KB |
Output is correct |
38 |
Correct |
220 ms |
21900 KB |
Output is correct |
39 |
Correct |
321 ms |
29864 KB |
Output is correct |
40 |
Correct |
441 ms |
37784 KB |
Output is correct |
41 |
Correct |
555 ms |
45804 KB |
Output is correct |
42 |
Correct |
681 ms |
53900 KB |
Output is correct |
43 |
Correct |
0 ms |
204 KB |
Output is correct |
44 |
Correct |
0 ms |
204 KB |
Output is correct |
45 |
Correct |
0 ms |
204 KB |
Output is correct |
46 |
Correct |
0 ms |
204 KB |
Output is correct |
47 |
Correct |
0 ms |
204 KB |
Output is correct |
48 |
Correct |
0 ms |
204 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
0 ms |
204 KB |
Output is correct |
51 |
Correct |
1 ms |
204 KB |
Output is correct |
52 |
Correct |
0 ms |
204 KB |
Output is correct |
53 |
Correct |
1 ms |
288 KB |
Output is correct |
54 |
Correct |
4 ms |
844 KB |
Output is correct |
55 |
Correct |
5 ms |
1228 KB |
Output is correct |
56 |
Correct |
306 ms |
34036 KB |
Output is correct |
57 |
Correct |
488 ms |
49248 KB |
Output is correct |
58 |
Correct |
517 ms |
49116 KB |
Output is correct |
59 |
Correct |
1 ms |
204 KB |
Output is correct |
60 |
Correct |
0 ms |
204 KB |
Output is correct |
61 |
Correct |
0 ms |
204 KB |
Output is correct |
62 |
Correct |
732 ms |
66168 KB |
Output is correct |
63 |
Correct |
724 ms |
66080 KB |
Output is correct |
64 |
Correct |
721 ms |
65924 KB |
Output is correct |
65 |
Correct |
8 ms |
1356 KB |
Output is correct |
66 |
Correct |
15 ms |
2508 KB |
Output is correct |
67 |
Correct |
314 ms |
31696 KB |
Output is correct |
68 |
Correct |
512 ms |
47408 KB |
Output is correct |
69 |
Correct |
726 ms |
63164 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 |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
314 ms |
36288 KB |
Output is correct |
10 |
Correct |
20 ms |
4068 KB |
Output is correct |
11 |
Correct |
136 ms |
19688 KB |
Output is correct |
12 |
Correct |
30 ms |
5956 KB |
Output is correct |
13 |
Correct |
98 ms |
14740 KB |
Output is correct |
14 |
Correct |
3 ms |
588 KB |
Output is correct |
15 |
Correct |
4 ms |
844 KB |
Output is correct |
16 |
Correct |
318 ms |
36332 KB |
Output is correct |
17 |
Correct |
726 ms |
72776 KB |
Output is correct |
18 |
Correct |
747 ms |
72940 KB |
Output is correct |
19 |
Correct |
724 ms |
66892 KB |
Output is correct |
20 |
Correct |
600 ms |
47400 KB |
Output is correct |
21 |
Correct |
594 ms |
55372 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
80 ms |
9376 KB |
Output is correct |
24 |
Incorrect |
44 ms |
5648 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
314 ms |
36288 KB |
Output is correct |
10 |
Correct |
20 ms |
4068 KB |
Output is correct |
11 |
Correct |
136 ms |
19688 KB |
Output is correct |
12 |
Correct |
30 ms |
5956 KB |
Output is correct |
13 |
Correct |
98 ms |
14740 KB |
Output is correct |
14 |
Correct |
3 ms |
588 KB |
Output is correct |
15 |
Correct |
4 ms |
844 KB |
Output is correct |
16 |
Correct |
318 ms |
36332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
691 ms |
55120 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
2 ms |
588 KB |
Output is correct |
26 |
Correct |
5 ms |
976 KB |
Output is correct |
27 |
Correct |
6 ms |
1276 KB |
Output is correct |
28 |
Correct |
211 ms |
22240 KB |
Output is correct |
29 |
Correct |
329 ms |
33316 KB |
Output is correct |
30 |
Correct |
529 ms |
44232 KB |
Output is correct |
31 |
Correct |
696 ms |
55188 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
0 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
204 KB |
Output is correct |
38 |
Correct |
0 ms |
204 KB |
Output is correct |
39 |
Correct |
0 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
204 KB |
Output is correct |
42 |
Correct |
0 ms |
204 KB |
Output is correct |
43 |
Correct |
4 ms |
844 KB |
Output is correct |
44 |
Correct |
6 ms |
1228 KB |
Output is correct |
45 |
Correct |
320 ms |
34060 KB |
Output is correct |
46 |
Correct |
501 ms |
49196 KB |
Output is correct |
47 |
Correct |
510 ms |
49212 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
0 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
0 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
204 KB |
Output is correct |
53 |
Correct |
0 ms |
204 KB |
Output is correct |
54 |
Correct |
0 ms |
204 KB |
Output is correct |
55 |
Correct |
620 ms |
49364 KB |
Output is correct |
56 |
Correct |
1 ms |
204 KB |
Output is correct |
57 |
Correct |
3 ms |
716 KB |
Output is correct |
58 |
Correct |
10 ms |
1848 KB |
Output is correct |
59 |
Incorrect |
24 ms |
2892 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
60 |
Halted |
0 ms |
0 KB |
- |