# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791470 | PoonYaPat | Roads (CEOI20_roads) | C++14 | 17 ms | 1876 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 <bits/stdc++.h>
using namespace std;
struct point {
int x,y;
};
typedef pair<point,point> ppp;
vector<ppp> v;
bool u;
int n;
bool comp(ppp A, ppp B) {
point a=A.first, b=B.first;
if (A.first.x==A.second.x) {
if (a.x!=b.x) return a.x<b.x;
else return a.y>b.y;
} else if (A.first.y==A.second.y) {
if (a.y!=b.y) return a.y<b.y;
return a.x>b.x;
} else if (u) {
if (a.y-a.x!=b.y-b.x) return a.y-a.x<b.y-b.x;
else return a.y>b.y;
} else {
if (a.x+a.y!=b.x+b.y) return a.x+a.y<b.x+b.y;
else return a.y>b.y;
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n;
for (int i=0; i<n; ++i) {
point a,b;
cin>>a.x>>a.y>>b.x>>b.y;
if (a.y>b.y) swap(a,b);
if (a.y==b.y && a.x>b.x) swap(a,b);
v.push_back(ppp(a,b));
}
if (v[0].first.x<v[0].second.x) u=true;
sort(v.begin(),v.end(),comp);
for (int i=1; i<v.size(); ++i) cout<<v[i-1].first.x<<" "<<v[i-1].first.y<<" "<<v[i].second.x<<" "<<v[i].second.y<<"\n";
}
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... |