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;
struct fountain{
int x, y, ind;
bool operator<(fountain&other){
return make_pair(x, y)<make_pair(other.x, other.y);
}
};
int construct_roads(vector<int> x, vector<int> y) {
int n = x.size();
vector<fountain> v;
for(int i = 0; i < n; i++){
v.push_back({y[i], x[i], i}); // FORDITOTT KOORDINATAK!!!!!4!!1!!!14!44!!!
}
sort(v.begin(), v.end());
int el = v[0].x;
vector<int> ru, rv, ra, rb;
for(int i = 1; i < n; i++){
if(v[i-1].x == v[i].x){
ru.push_back(v[i-1].ind);
rv.push_back(v[i].ind);
ra.push_back(v[i].x+1);
rb.push_back(3);
} else if(v[i-1].y == v[i].y && v[i].x-v[i-1].x == 2 && v[i-1].x == el){
ru.push_back(v[i-1].ind);
rv.push_back(v[i].ind);
ra.push_back(v[i].x-1);
rb.push_back(v[i].y == 2 ? 1 : 5);
el = v[i].x;
}
if(i > 1){
if(v[i-2].x == v[i].x){
ru.push_back(v[i-2].ind);
rv.push_back(v[i].ind);
ra.push_back(v[i].x+1);
rb.push_back(3);
} else if(v[i-2].y == v[i].y && v[i].x-v[i-2].x == 2 && v[i-2].x == el){
ru.push_back(v[i-2].ind);
rv.push_back(v[i].ind);
ra.push_back(v[i].x-1);
rb.push_back(v[i].y == 2 ? 1 : 5);
el = v[i].x;
}
}
}
if(el == v.back().x){
build(rv, ru, rb, ra);
return 1;
} else {
return 0;
}
}
# | 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... |