Submission #1051715

#TimeUsernameProblemLanguageResultExecution timeMemory
1051715MarwenElarbiFountain Parks (IOI21_parks)C++17
5 / 100
73 ms16592 KiB
#include <bits/stdc++.h>
using namespace std;
#include "parks.h"
#define pb push_back
#define fi first
#define se second
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<int,int>> tab(n);
    for (int i = 0; i < n; ++i) tab[i]={y[i],i};
    sort(tab.begin(),tab.end());
    bool test=true;
    for (int i = 1; i < n; ++i)
    {
        if(tab[i].fi-tab[i-1].fi>2) test=false;
    }
    if(!test) return 0;
    for (int i = 0; i < n-1; ++i)
    {
        a.pb(3);
        b.pb(tab[i].fi+1);
        u.pb(tab[i+1].se);
        v.pb(tab[i].se);
    }
    build(u, v, a, b);
    return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...