Submission #1051760

# Submission time Handle Problem Language Result Execution time Memory
1051760 2024-08-10T09:36:59 Z MarwenElarbi Fountain Parks (IOI21_parks) C++17
5 / 100
90 ms 29508 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 pre[nax];
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;
    vector<pair<int,int>> tab[nax];
    for (int i = 0; i < n; ++i) tab[y[i]].pb({x[i],i});
    for (int i = 0; i < n; ++i) cor.pb({{y[i],x[i]},i});
    for (int i = 2; i < nax; ++i) pre[i]=pre[i-1]+tab[i].size();
    sort(cor.begin(),cor.end());
    bool test=true;
    for (int i = 0; i < n; ++i)
    {
        if(pre[y[i]-1]>0&&tab[y[i]-2].size()==0) test=false;
        if(pre[y[i]-1]>0&&tab[y[i]].size()==1&&tab[y[i]-2].size()==1){
            if(abs(tab[y[i]][0].fi-tab[y[i]-2][0].fi>0)) 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){
                a.pb(1);
                b.pb(cor[i].fi.fi+1);
                u.pb(cor[i].se);
                v.pb(cor[i+2].se);
            }
        }
        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 2 ms 4952 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 3 ms 5820 KB Output is correct
5 Correct 3 ms 5724 KB Output is correct
6 Correct 3 ms 5724 KB Output is correct
7 Correct 4 ms 5836 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 42 ms 16888 KB Output is correct
10 Correct 6 ms 7080 KB Output is correct
11 Correct 18 ms 11732 KB Output is correct
12 Correct 7 ms 7532 KB Output is correct
13 Correct 9 ms 8408 KB Output is correct
14 Correct 3 ms 5848 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 39 ms 16908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 3 ms 5820 KB Output is correct
5 Correct 3 ms 5724 KB Output is correct
6 Correct 3 ms 5724 KB Output is correct
7 Correct 4 ms 5836 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 42 ms 16888 KB Output is correct
10 Correct 6 ms 7080 KB Output is correct
11 Correct 18 ms 11732 KB Output is correct
12 Correct 7 ms 7532 KB Output is correct
13 Correct 9 ms 8408 KB Output is correct
14 Correct 3 ms 5848 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 39 ms 16908 KB Output is correct
17 Incorrect 5 ms 5724 KB Tree (a[2], b[2]) = (1, 3) is not adjacent to edge between u[2]=2 @(4, 2) and v[2]=0 @(4, 4)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 3 ms 5820 KB Output is correct
5 Correct 3 ms 5724 KB Output is correct
6 Correct 3 ms 5724 KB Output is correct
7 Correct 4 ms 5836 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 42 ms 16888 KB Output is correct
10 Correct 6 ms 7080 KB Output is correct
11 Correct 18 ms 11732 KB Output is correct
12 Correct 7 ms 7532 KB Output is correct
13 Correct 9 ms 8408 KB Output is correct
14 Correct 3 ms 5848 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 39 ms 16908 KB Output is correct
17 Incorrect 5 ms 5724 KB Tree (a[2], b[2]) = (1, 3) is not adjacent to edge between u[2]=2 @(4, 2) and v[2]=0 @(4, 4)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 3 ms 5820 KB Output is correct
5 Correct 3 ms 5724 KB Output is correct
6 Correct 3 ms 5724 KB Output is correct
7 Correct 4 ms 5836 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 42 ms 16888 KB Output is correct
10 Correct 6 ms 7080 KB Output is correct
11 Correct 18 ms 11732 KB Output is correct
12 Correct 7 ms 7532 KB Output is correct
13 Correct 9 ms 8408 KB Output is correct
14 Correct 3 ms 5848 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 39 ms 16908 KB Output is correct
17 Incorrect 3 ms 5720 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 2 ms 4952 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 3 ms 5820 KB Output is correct
5 Correct 3 ms 5724 KB Output is correct
6 Correct 3 ms 5724 KB Output is correct
7 Correct 4 ms 5836 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 42 ms 16888 KB Output is correct
10 Correct 6 ms 7080 KB Output is correct
11 Correct 18 ms 11732 KB Output is correct
12 Correct 7 ms 7532 KB Output is correct
13 Correct 9 ms 8408 KB Output is correct
14 Correct 3 ms 5848 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 39 ms 16908 KB Output is correct
17 Incorrect 90 ms 29508 KB Tree (a[1], b[1]) = (3, 1) is not adjacent to edge between u[1]=22196 @(4, 2) and v[1]=134526 @(6, 2)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 5724 KB Output is correct
3 Correct 3 ms 5724 KB Output is correct
4 Correct 3 ms 5820 KB Output is correct
5 Correct 3 ms 5724 KB Output is correct
6 Correct 3 ms 5724 KB Output is correct
7 Correct 4 ms 5836 KB Output is correct
8 Correct 3 ms 5724 KB Output is correct
9 Correct 42 ms 16888 KB Output is correct
10 Correct 6 ms 7080 KB Output is correct
11 Correct 18 ms 11732 KB Output is correct
12 Correct 7 ms 7532 KB Output is correct
13 Correct 9 ms 8408 KB Output is correct
14 Correct 3 ms 5848 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 39 ms 16908 KB Output is correct
17 Incorrect 5 ms 5724 KB Tree (a[2], b[2]) = (1, 3) is not adjacent to edge between u[2]=2 @(4, 2) and v[2]=0 @(4, 4)
18 Halted 0 ms 0 KB -