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;
typedef long long ll;
typedef long double ld;
const int N=1e5+5;
const ld eps=1e-9;
struct point{
ll x,y;
point():x(0),y(0){}
point(ll x,ll y):x(x),y(y){}
const bool operator<(const point &o)const{
if(y==o.y)return x<o.x;
return y<o.y;
}
};
struct line{
point p1,p2;
line(point p1,point p2):p1(min(p1,p2)),p2(max(p1,p2)){}
line(ll x1,ll y1,ll x2,ll y2){
*this=line(point(x1,y1),point(x2,y2));
}
const ld dx()const{
return p1.x-p2.x;
}
const ld dy()const{
return p1.y-p2.y;
}
const ld c()const{
if(abs(dx())<eps)return p1.x;
return p1.y-dy()/dx()*p1.x;
}
const bool operator<(const line &o)const{
ld a=c(),b=o.c();
if(abs(a-b)<eps)return p1<o.p1;
return a<b;
}
};
int n;
vector<line> vec;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i=1;i<=n;i++){
ll a,b,c,d;
cin >> a >> b >> c >> d;
vec.emplace_back(line(a,b,c,d));
}
sort(vec.begin(),vec.end());
for(int i=1;i<n;i++){
cout << vec[i-1].p2.x << " " << vec[i-1].p2.y << " " << vec[i].p1.x << " " << vec[i].p1.y << "\n";
}
}
# | 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... |