이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
struct line{
int x1,y1,x2,y2;
line(){}
line(int a,int b,int c,int d){
x1=a,y1=b,x2=c,y2=d;
if(y1>y2){
swap(x1,x2);
swap(y1,y2);
}
}
};
bool operator<(line a,line b){
if(a.x1==b.x1){
return a.y1<b.y1;
}
return a.x1<b.x1;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<line> v(n);
for(int i=0;i<n;i++){
int a,b,c,d;cin>>a>>b>>c>>d;
v[i]=line(a,b,c,d);
}
int tmp1=v[0].x2-v[0].x1;
int tmp2=v[0].y2-v[0].y1;
if(tmp2==0){
for(int i=0;i<n;i++){
swap(v[i].x1,v[i].y1);
swap(v[i].x2,v[i].y2);
}
sort(all(v));
for(int i=0;i<n;i++){
swap(v[i].x1,v[i].y1);
swap(v[i].x2,v[i].y2);
}
for(int i=1;i<n;i++){
cout<<v[i-1].x2<<' '<<v[i-1].y2<<' '<<v[i].x1<<' '<<v[i].y1<<endl;
}
return 0;
}
sort(all(v),[&](line a,line b){
if(a.y2*tmp1-a.x2*tmp2==b.y2*tmp1-b.x2*tmp2){
return a.y2<b.y2;
}
return a.y2*tmp1-a.x2*tmp2<b.y2*tmp1-b.x2*tmp2;
});
for(int i=1;i<n;i++){
cout<<v[i-1].x2<<' '<<v[i-1].y2<<' '<<v[i].x1<<' '<<v[i].y1<<endl;
}
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... |