Submission #1051791

# Submission time Handle Problem Language Result Execution time Memory
1051791 2024-08-10T09:47:26 Z MarwenElarbi Fountain Parks (IOI21_parks) C++17
15 / 100
81 ms 22088 KB
#include <bits/stdc++.h>
using namespace std;
#include "parks.h"
#define pb push_back
#define fi first
#define se second
const int nax=2e5+5;
int dis(pair<int,int> a,pair<int,int> b){
    return abs(a.fi-b.fi)+abs(a.se-b.se);
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    std::vector<int> u, v, a, b;
    int n=y.size();
    vector<pair<pair<int,int>,int>> cor;
    for (int i = 0; i < n; ++i) cor.pb({{y[i],x[i]},i});
    sort(cor.begin(),cor.end());
    bool test=true;
    for (int i = 1; i < n; ++i)
    {
        if(dis(cor[i].fi,cor[i-1].fi)==2) continue;
        if(i>1&&dis(cor[i].fi,cor[i-2].fi)==2) continue;
        if(i<n-1&&dis(cor[i].fi,cor[i+1].fi)==2&&dis(cor[i+1].fi,cor[i-1].fi)==2) continue;
        test=false;
    }
    if(!test) return 0;
    for (int i = 0; i < n-1; ++i)
    {
        if(i<n-2){
            if(dis(cor[i].fi,cor[i+2].fi)==2){
                if(cor[i].fi.se==2) a.pb(1);
                else a.pb(5);
                b.pb(cor[i].fi.fi+1);
                u.pb(cor[i].se);
                v.pb(cor[i+2].se);
            }
        }
        if(dis(cor[i].fi,cor[i+1].fi)!=2) continue;
        if(cor[i].fi.se!=cor[i+1].fi.se){
            a.pb(3);
            b.pb(cor[i].fi.fi-1);
            u.pb(cor[i].se);
            v.pb(cor[i+1].se);
        }else{
            if(cor[i].fi.se==2) a.pb(1);
            else a.pb(5);
            b.pb(cor[i].fi.fi+1);
            u.pb(cor[i].se);
            v.pb(cor[i+1].se);
        }
    }
    build(u, v, a, b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 31 ms 8232 KB Output is correct
10 Correct 3 ms 1192 KB Output is correct
11 Correct 14 ms 4564 KB Output is correct
12 Correct 7 ms 1648 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 31 ms 8156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 31 ms 8232 KB Output is correct
10 Correct 3 ms 1192 KB Output is correct
11 Correct 14 ms 4564 KB Output is correct
12 Correct 7 ms 1648 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 31 ms 8156 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 78 ms 21864 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 30 ms 9116 KB Output is correct
29 Correct 46 ms 12748 KB Output is correct
30 Correct 70 ms 18124 KB Output is correct
31 Correct 81 ms 22088 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 604 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 436 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 452 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 36 ms 9044 KB Output is correct
46 Correct 52 ms 14124 KB Output is correct
47 Correct 49 ms 14988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 31 ms 8232 KB Output is correct
10 Correct 3 ms 1192 KB Output is correct
11 Correct 14 ms 4564 KB Output is correct
12 Correct 7 ms 1648 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 31 ms 8156 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 78 ms 21864 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 30 ms 9116 KB Output is correct
29 Correct 46 ms 12748 KB Output is correct
30 Correct 70 ms 18124 KB Output is correct
31 Correct 81 ms 22088 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 604 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 436 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 452 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 36 ms 9044 KB Output is correct
46 Correct 52 ms 14124 KB Output is correct
47 Correct 49 ms 14988 KB Output is correct
48 Incorrect 0 ms 348 KB Tree (a[1], b[1]) = (3, 1) is not adjacent to edge between u[1]=1 @(4, 2) and v[1]=0 @(6, 2)
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 31 ms 8232 KB Output is correct
10 Correct 3 ms 1192 KB Output is correct
11 Correct 14 ms 4564 KB Output is correct
12 Correct 7 ms 1648 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 31 ms 8156 KB Output is correct
17 Incorrect 0 ms 348 KB Tree (a[0], b[0]) = (3, 1) is not adjacent to edge between u[0]=2 @(199998, 2) and v[0]=0 @(200000, 2)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 31 ms 8232 KB Output is correct
10 Correct 3 ms 1192 KB Output is correct
11 Correct 14 ms 4564 KB Output is correct
12 Correct 7 ms 1648 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 31 ms 8156 KB Output is correct
17 Incorrect 49 ms 6684 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 31 ms 8232 KB Output is correct
10 Correct 3 ms 1192 KB Output is correct
11 Correct 14 ms 4564 KB Output is correct
12 Correct 7 ms 1648 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 31 ms 8156 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 78 ms 21864 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 30 ms 9116 KB Output is correct
29 Correct 46 ms 12748 KB Output is correct
30 Correct 70 ms 18124 KB Output is correct
31 Correct 81 ms 22088 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 604 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 436 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 452 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 36 ms 9044 KB Output is correct
46 Correct 52 ms 14124 KB Output is correct
47 Correct 49 ms 14988 KB Output is correct
48 Incorrect 0 ms 348 KB Tree (a[1], b[1]) = (3, 1) is not adjacent to edge between u[1]=1 @(4, 2) and v[1]=0 @(6, 2)
49 Halted 0 ms 0 KB -