# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
551088 |
2022-04-19T20:30:49 Z |
1ne |
Fountain Parks (IOI21_parks) |
C++17 |
|
969 ms |
104736 KB |
#include "parks.h"
#include<bits/stdc++.h>
using namespace std;
struct edges{
int x,y,x1,y1;
};
int construct_roads(std::vector<int> x, std::vector<int> y) {
map<pair<int,int>,bool>mp,got;
map<pair<int,int>,int>index;
int n = (int)x.size();
for (int i = 0;i<n;++i){
mp[{x[i],y[i]}] = true;
got[{x[i],y[i]}] = false;
index[{x[i],y[i]}] = i;
}
vector<edges>ans;
vector<int>dx = {2,0,-2,0};
vector<int>dy = {0,2,0,-2};
function<void(int,int)> dfs = [&](int u,int v){
got[{u,v}] = true;
for (int i = 0;i<4;++i){
int xx = u + dx[i];
int yy = v + dy[i];
if (mp[{xx,yy}] && !got[{xx,yy}]){
ans.push_back({min(u,xx),min(v,yy),max(xx,u),max(yy,v)});
dfs(xx,yy);
}
}
};
bool ok = true;
dfs(x[0],y[0]);
for (int i = 0;i<n;++i){
if (!got[{x[i],y[i]}]){
ok=false;
break;
}
}
if (!ok){
return 0;
}
vector<int>u,v,a,b;
for (auto z:ans){
u.push_back(index[{z.x,z.y}]);
v.push_back(index[{z.x1,z.y1}]);
a.push_back(z.x + 1);
b.push_back(z.y + 1);
}
build(u,v,a,b);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
288 KB |
Output is correct |
9 |
Correct |
363 ms |
51696 KB |
Output is correct |
10 |
Correct |
24 ms |
5536 KB |
Output is correct |
11 |
Correct |
157 ms |
28544 KB |
Output is correct |
12 |
Correct |
33 ms |
8156 KB |
Output is correct |
13 |
Correct |
77 ms |
17708 KB |
Output is correct |
14 |
Correct |
2 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
852 KB |
Output is correct |
16 |
Correct |
404 ms |
46564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
288 KB |
Output is correct |
9 |
Correct |
363 ms |
51696 KB |
Output is correct |
10 |
Correct |
24 ms |
5536 KB |
Output is correct |
11 |
Correct |
157 ms |
28544 KB |
Output is correct |
12 |
Correct |
33 ms |
8156 KB |
Output is correct |
13 |
Correct |
77 ms |
17708 KB |
Output is correct |
14 |
Correct |
2 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
852 KB |
Output is correct |
16 |
Correct |
404 ms |
46564 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Tree @(3, 3) appears more than once: for edges on positions 1 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
288 KB |
Output is correct |
9 |
Correct |
363 ms |
51696 KB |
Output is correct |
10 |
Correct |
24 ms |
5536 KB |
Output is correct |
11 |
Correct |
157 ms |
28544 KB |
Output is correct |
12 |
Correct |
33 ms |
8156 KB |
Output is correct |
13 |
Correct |
77 ms |
17708 KB |
Output is correct |
14 |
Correct |
2 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
852 KB |
Output is correct |
16 |
Correct |
404 ms |
46564 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Tree @(3, 3) appears more than once: for edges on positions 1 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
288 KB |
Output is correct |
9 |
Correct |
363 ms |
51696 KB |
Output is correct |
10 |
Correct |
24 ms |
5536 KB |
Output is correct |
11 |
Correct |
157 ms |
28544 KB |
Output is correct |
12 |
Correct |
33 ms |
8156 KB |
Output is correct |
13 |
Correct |
77 ms |
17708 KB |
Output is correct |
14 |
Correct |
2 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
852 KB |
Output is correct |
16 |
Correct |
404 ms |
46564 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
1 ms |
296 KB |
Output is correct |
19 |
Correct |
1 ms |
304 KB |
Output is correct |
20 |
Incorrect |
919 ms |
92124 KB |
Tree @(195231, 4773) appears more than once: for edges on positions 0 and 1 |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
288 KB |
Output is correct |
9 |
Correct |
363 ms |
51696 KB |
Output is correct |
10 |
Correct |
24 ms |
5536 KB |
Output is correct |
11 |
Correct |
157 ms |
28544 KB |
Output is correct |
12 |
Correct |
33 ms |
8156 KB |
Output is correct |
13 |
Correct |
77 ms |
17708 KB |
Output is correct |
14 |
Correct |
2 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
852 KB |
Output is correct |
16 |
Correct |
404 ms |
46564 KB |
Output is correct |
17 |
Incorrect |
969 ms |
104736 KB |
Tree @(3, 3) appears more than once: for edges on positions 108789 and 108790 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
288 KB |
Output is correct |
9 |
Correct |
363 ms |
51696 KB |
Output is correct |
10 |
Correct |
24 ms |
5536 KB |
Output is correct |
11 |
Correct |
157 ms |
28544 KB |
Output is correct |
12 |
Correct |
33 ms |
8156 KB |
Output is correct |
13 |
Correct |
77 ms |
17708 KB |
Output is correct |
14 |
Correct |
2 ms |
560 KB |
Output is correct |
15 |
Correct |
3 ms |
852 KB |
Output is correct |
16 |
Correct |
404 ms |
46564 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Tree @(3, 3) appears more than once: for edges on positions 1 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |