#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2e5+6;
vector<int>g[MAXN];
map<pair<int,int>,int> tochki;
bool vis[MAXN];
vector<pair<int,int> >roads;
int cnt;
void dfs(int u)
{
vis[u]=1;
cnt++;
for(auto xd:g[u])
{
if(vis[xd])continue;
dfs(xd);
roads.push_back({u,xd});
}
}
int construct_roads(vector<int> x, vector<int> y) {
if (x.size() == 1) {
build({}, {}, {}, {});
return 1;
}
for(int i=0;i<x.size();i++)
{
tochki[make_pair(x[i],y[i])]=i;
}
for(int i=0;i<x.size();i++)
{
if(tochki.count(make_pair(x[i],y[i]-2)))
{
g[i].push_back(tochki[make_pair(x[i],y[i]-2)]);
}
if(tochki.count(make_pair(x[i],y[i]+2)))
{
g[i].push_back(tochki[make_pair(x[i],y[i]+2)]);
}
if(tochki.count(make_pair(x[i]+2,y[i])))
{
g[i].push_back(tochki[make_pair(x[i]+2,y[i])]);
}
if(tochki.count(make_pair(x[i]-2,y[i])))
{
g[i].push_back(tochki[make_pair(x[i]-2,y[i])]);
}
}
dfs(0);
if(cnt!=x.size())return 0;
vector<int>u;
vector<int>v;
vector<int>a;
vector<int>b;
for(int i=0;i<roads.size();i++)
{
u.push_back(roads[i].first);
v.push_back(roads[i].second);
if(x[roads[i].first]==x[roads[i].second])
{
int x1=x[roads[i].first];
int y1=min(y[roads[i].first],y[roads[i].second]);
if((x1+y1)%4==0)
{
a.push_back(x1+1);
b.push_back(y1+1);
}
else
{
a.push_back(x1-1);
b.push_back(y1+1);
}
}
else
{
int y1=y[roads[i].first];
int x1=min(x[roads[i].first],x[roads[i].second]);
if((x1+y1)%4==0)
{
a.push_back(x1+1);
b.push_back(y1-1);
}
else
{
a.push_back(x1+1);
b.push_back(y1+1);
}
}
}
build(u,v,a,b);
return 1;
}
Compilation message
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int i=0;i<x.size();i++)
| ~^~~~~~~~~
parks.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i=0;i<x.size();i++)
| ~^~~~~~~~~
parks.cpp:50:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | if(cnt!=x.size())return 0;
| ~~~^~~~~~~~~~
parks.cpp:55:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i=0;i<roads.size();i++)
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4952 KB |
Output is correct |
9 |
Correct |
144 ms |
30392 KB |
Output is correct |
10 |
Correct |
11 ms |
7772 KB |
Output is correct |
11 |
Correct |
61 ms |
18980 KB |
Output is correct |
12 |
Correct |
16 ms |
9052 KB |
Output is correct |
13 |
Correct |
39 ms |
12680 KB |
Output is correct |
14 |
Correct |
2 ms |
5208 KB |
Output is correct |
15 |
Correct |
3 ms |
5208 KB |
Output is correct |
16 |
Correct |
151 ms |
27316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4952 KB |
Output is correct |
9 |
Correct |
144 ms |
30392 KB |
Output is correct |
10 |
Correct |
11 ms |
7772 KB |
Output is correct |
11 |
Correct |
61 ms |
18980 KB |
Output is correct |
12 |
Correct |
16 ms |
9052 KB |
Output is correct |
13 |
Correct |
39 ms |
12680 KB |
Output is correct |
14 |
Correct |
2 ms |
5208 KB |
Output is correct |
15 |
Correct |
3 ms |
5208 KB |
Output is correct |
16 |
Correct |
151 ms |
27316 KB |
Output is correct |
17 |
Incorrect |
2 ms |
4952 KB |
Tree @(3, 3) appears more than once: for edges on positions 0 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4952 KB |
Output is correct |
9 |
Correct |
144 ms |
30392 KB |
Output is correct |
10 |
Correct |
11 ms |
7772 KB |
Output is correct |
11 |
Correct |
61 ms |
18980 KB |
Output is correct |
12 |
Correct |
16 ms |
9052 KB |
Output is correct |
13 |
Correct |
39 ms |
12680 KB |
Output is correct |
14 |
Correct |
2 ms |
5208 KB |
Output is correct |
15 |
Correct |
3 ms |
5208 KB |
Output is correct |
16 |
Correct |
151 ms |
27316 KB |
Output is correct |
17 |
Incorrect |
2 ms |
4952 KB |
Tree @(3, 3) appears more than once: for edges on positions 0 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4952 KB |
Output is correct |
9 |
Correct |
144 ms |
30392 KB |
Output is correct |
10 |
Correct |
11 ms |
7772 KB |
Output is correct |
11 |
Correct |
61 ms |
18980 KB |
Output is correct |
12 |
Correct |
16 ms |
9052 KB |
Output is correct |
13 |
Correct |
39 ms |
12680 KB |
Output is correct |
14 |
Correct |
2 ms |
5208 KB |
Output is correct |
15 |
Correct |
3 ms |
5208 KB |
Output is correct |
16 |
Correct |
151 ms |
27316 KB |
Output is correct |
17 |
Correct |
1 ms |
4952 KB |
Output is correct |
18 |
Correct |
1 ms |
4956 KB |
Output is correct |
19 |
Correct |
2 ms |
4956 KB |
Output is correct |
20 |
Correct |
428 ms |
57964 KB |
Output is correct |
21 |
Correct |
435 ms |
54764 KB |
Output is correct |
22 |
Correct |
400 ms |
52640 KB |
Output is correct |
23 |
Correct |
309 ms |
45456 KB |
Output is correct |
24 |
Correct |
256 ms |
20716 KB |
Output is correct |
25 |
Correct |
390 ms |
27216 KB |
Output is correct |
26 |
Correct |
337 ms |
27188 KB |
Output is correct |
27 |
Correct |
435 ms |
41704 KB |
Output is correct |
28 |
Correct |
457 ms |
41512 KB |
Output is correct |
29 |
Correct |
470 ms |
41628 KB |
Output is correct |
30 |
Correct |
454 ms |
41696 KB |
Output is correct |
31 |
Correct |
2 ms |
4956 KB |
Output is correct |
32 |
Correct |
22 ms |
8276 KB |
Output is correct |
33 |
Correct |
89 ms |
14244 KB |
Output is correct |
34 |
Correct |
418 ms |
57752 KB |
Output is correct |
35 |
Correct |
12 ms |
6492 KB |
Output is correct |
36 |
Correct |
67 ms |
11348 KB |
Output is correct |
37 |
Correct |
150 ms |
17488 KB |
Output is correct |
38 |
Correct |
143 ms |
21588 KB |
Output is correct |
39 |
Correct |
204 ms |
26932 KB |
Output is correct |
40 |
Correct |
291 ms |
34196 KB |
Output is correct |
41 |
Correct |
351 ms |
39576 KB |
Output is correct |
42 |
Correct |
454 ms |
45072 KB |
Output is correct |
43 |
Correct |
2 ms |
4956 KB |
Output is correct |
44 |
Correct |
1 ms |
5044 KB |
Output is correct |
45 |
Correct |
1 ms |
4956 KB |
Output is correct |
46 |
Correct |
1 ms |
4956 KB |
Output is correct |
47 |
Correct |
1 ms |
4956 KB |
Output is correct |
48 |
Correct |
2 ms |
4956 KB |
Output is correct |
49 |
Correct |
2 ms |
4956 KB |
Output is correct |
50 |
Correct |
2 ms |
4956 KB |
Output is correct |
51 |
Correct |
1 ms |
4956 KB |
Output is correct |
52 |
Correct |
3 ms |
4952 KB |
Output is correct |
53 |
Correct |
2 ms |
4956 KB |
Output is correct |
54 |
Correct |
3 ms |
5468 KB |
Output is correct |
55 |
Correct |
4 ms |
5460 KB |
Output is correct |
56 |
Correct |
176 ms |
29044 KB |
Output is correct |
57 |
Correct |
274 ms |
41244 KB |
Output is correct |
58 |
Correct |
290 ms |
40592 KB |
Output is correct |
59 |
Correct |
2 ms |
4956 KB |
Output is correct |
60 |
Correct |
2 ms |
5164 KB |
Output is correct |
61 |
Correct |
1 ms |
5172 KB |
Output is correct |
62 |
Correct |
332 ms |
54508 KB |
Output is correct |
63 |
Correct |
338 ms |
54556 KB |
Output is correct |
64 |
Correct |
375 ms |
56076 KB |
Output is correct |
65 |
Correct |
5 ms |
5724 KB |
Output is correct |
66 |
Correct |
10 ms |
6068 KB |
Output is correct |
67 |
Correct |
168 ms |
26416 KB |
Output is correct |
68 |
Correct |
279 ms |
40268 KB |
Output is correct |
69 |
Correct |
393 ms |
48520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4952 KB |
Output is correct |
9 |
Correct |
144 ms |
30392 KB |
Output is correct |
10 |
Correct |
11 ms |
7772 KB |
Output is correct |
11 |
Correct |
61 ms |
18980 KB |
Output is correct |
12 |
Correct |
16 ms |
9052 KB |
Output is correct |
13 |
Correct |
39 ms |
12680 KB |
Output is correct |
14 |
Correct |
2 ms |
5208 KB |
Output is correct |
15 |
Correct |
3 ms |
5208 KB |
Output is correct |
16 |
Correct |
151 ms |
27316 KB |
Output is correct |
17 |
Correct |
364 ms |
57620 KB |
Output is correct |
18 |
Correct |
412 ms |
51460 KB |
Output is correct |
19 |
Correct |
410 ms |
58112 KB |
Output is correct |
20 |
Correct |
449 ms |
48444 KB |
Output is correct |
21 |
Correct |
443 ms |
43004 KB |
Output is correct |
22 |
Correct |
2 ms |
4956 KB |
Output is correct |
23 |
Correct |
52 ms |
11524 KB |
Output is correct |
24 |
Correct |
30 ms |
8052 KB |
Output is correct |
25 |
Correct |
104 ms |
14160 KB |
Output is correct |
26 |
Correct |
226 ms |
20580 KB |
Output is correct |
27 |
Correct |
190 ms |
28344 KB |
Output is correct |
28 |
Correct |
266 ms |
34160 KB |
Output is correct |
29 |
Correct |
343 ms |
39956 KB |
Output is correct |
30 |
Correct |
374 ms |
46228 KB |
Output is correct |
31 |
Correct |
458 ms |
49860 KB |
Output is correct |
32 |
Correct |
402 ms |
55712 KB |
Output is correct |
33 |
Correct |
355 ms |
58920 KB |
Output is correct |
34 |
Correct |
6 ms |
5724 KB |
Output is correct |
35 |
Correct |
10 ms |
6232 KB |
Output is correct |
36 |
Correct |
178 ms |
27064 KB |
Output is correct |
37 |
Correct |
269 ms |
39532 KB |
Output is correct |
38 |
Correct |
396 ms |
50160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4952 KB |
Output is correct |
9 |
Correct |
144 ms |
30392 KB |
Output is correct |
10 |
Correct |
11 ms |
7772 KB |
Output is correct |
11 |
Correct |
61 ms |
18980 KB |
Output is correct |
12 |
Correct |
16 ms |
9052 KB |
Output is correct |
13 |
Correct |
39 ms |
12680 KB |
Output is correct |
14 |
Correct |
2 ms |
5208 KB |
Output is correct |
15 |
Correct |
3 ms |
5208 KB |
Output is correct |
16 |
Correct |
151 ms |
27316 KB |
Output is correct |
17 |
Incorrect |
2 ms |
4952 KB |
Tree @(3, 3) appears more than once: for edges on positions 0 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |