Submission #791402

#TimeUsernameProblemLanguageResultExecution timeMemory
791402ttamxRoads (CEOI20_roads)C++14
30 / 100
86 ms9372 KiB
#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 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...