# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
970301 | mychecksedad | Fountain Parks (IOI21_parks) | C++17 | 100 ms | 17796 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n';
#define ll long long int
const int N = 3e5+10;
int construct_roads(std::vector<int> x, std::vector<int> y) {
if (x.size() == 1) {
build({}, {}, {}, {});
return 1;
}
int n = x.size();
vector<int> u, v, a, b;
vector<pair<int, int>> L, R;
for(int i = 0; i < n; ++i){
if(x[i] == 2) L.pb({y[i], i});
else R.pb({y[i], i});
}
sort(all(L));
sort(all(R));
for(int i = 0; i + 1 < L.size(); ++i){
if(L[i + 1].first - L[i].first > 2){
return 0;
}
u.pb(L[i].second);
v.pb(L[i + 1].second);
a.pb(1);
b.pb(L[i + 1].first + L[i].first>>1);
}
for(int i = 0; i + 1 < R.size(); ++i){
if(R[i + 1].first - R[i].first > 2){
return 0;
}
u.pb(R[i].second);
v.pb(R[i + 1].second);
a.pb(5);
b.pb(R[i + 1].first + R[i].first>>1);
}
if(!R.empty() && !L.empty()){
if(L[0].first > R.back().first) return 0;
if(R[0].first > L.back().first) return 0;
if(R[0].first > L[0].first) L.swap(R);
for(int i = 0; i < R.size(); ++i){
if(R[i].first == L[0].first){
u.pb(R[i].second);
v.pb(L[0].second);
a.pb(3);
b.pb(R[i].first - 1);
break;
}
}
}
build(u, v, a, b);
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |