#include <vector>
#include <algorithm>
using namespace std;
void build(std::vector<int> u, std::vector<int> v, std::vector<int> a, std::vector<int> b);
int construct_roads(std::vector<int> x, std::vector<int> y)
{
int n=x.size();
vector<int> u,v,a,b;
vector<vector<int>> cp;
for(int i=0;i<n;i++)
cp.push_back({y[i],x[i],i});
sort(begin(cp),end(cp));
for(int i=0;(i+1)<n;i++)
{
// go from y[i] to y[i+1]
if((cp[i+1][0]-cp[i][0]) != 2)
return 0;
u.push_back(cp[i][2]);
v.push_back(cp[i+1][2]);
a.push_back(cp[i][1]-1);
b.push_back(cp[i][0]+1);
}
build(u,v,a,b);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
53 ms |
12556 KB |
Output is correct |
10 |
Correct |
5 ms |
1684 KB |
Output is correct |
11 |
Correct |
23 ms |
6672 KB |
Output is correct |
12 |
Correct |
10 ms |
2196 KB |
Output is correct |
13 |
Correct |
10 ms |
4112 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
59 ms |
12556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
53 ms |
12556 KB |
Output is correct |
10 |
Correct |
5 ms |
1684 KB |
Output is correct |
11 |
Correct |
23 ms |
6672 KB |
Output is correct |
12 |
Correct |
10 ms |
2196 KB |
Output is correct |
13 |
Correct |
10 ms |
4112 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
59 ms |
12556 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
53 ms |
12556 KB |
Output is correct |
10 |
Correct |
5 ms |
1684 KB |
Output is correct |
11 |
Correct |
23 ms |
6672 KB |
Output is correct |
12 |
Correct |
10 ms |
2196 KB |
Output is correct |
13 |
Correct |
10 ms |
4112 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
59 ms |
12556 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
53 ms |
12556 KB |
Output is correct |
10 |
Correct |
5 ms |
1684 KB |
Output is correct |
11 |
Correct |
23 ms |
6672 KB |
Output is correct |
12 |
Correct |
10 ms |
2196 KB |
Output is correct |
13 |
Correct |
10 ms |
4112 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
59 ms |
12556 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
53 ms |
12556 KB |
Output is correct |
10 |
Correct |
5 ms |
1684 KB |
Output is correct |
11 |
Correct |
23 ms |
6672 KB |
Output is correct |
12 |
Correct |
10 ms |
2196 KB |
Output is correct |
13 |
Correct |
10 ms |
4112 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
59 ms |
12556 KB |
Output is correct |
17 |
Incorrect |
69 ms |
15868 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
53 ms |
12556 KB |
Output is correct |
10 |
Correct |
5 ms |
1684 KB |
Output is correct |
11 |
Correct |
23 ms |
6672 KB |
Output is correct |
12 |
Correct |
10 ms |
2196 KB |
Output is correct |
13 |
Correct |
10 ms |
4112 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
59 ms |
12556 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |