#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> pii;
typedef tree<pii ,null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const ll MAXN = 301;
const ll MOD = 1e9+7;
const ll INF = 1e6+10;
long double value(pair<pii, pii> v){
long double x1,x2,y1,y2;
x1 = (long double)v.first.first;
y1 = (long double)v.first.second;
x2 = (long double)v.second.first;
y2 = (long double)v.second.second;
y2-=y1;
x2-=x1;
x1 = (long double)((x1*y2)/x2);
return (long double)(y1-x1);
}
bool comp( pair<pii, pii> v, pair<pii, pii>b){
//return true if v is smaller than b
long double x1,x2,y1,y2,x3,y3;
x1 = (long double)v.first.first;
y1 = (long double)v.first.second;
x2 = (long double)v.second.first;
y2 = (long double)v.second.second;
x3 = (long double)b.second.first;
y3 = (long double)b.second.second;
long double res = (y1*x3+y2*x1+y3*x2-y3*x1-y1*x2-y2*x3)/2;
if(res==0)return x1<x3;
return res>0;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n,i,x1,x2,y1,y2;
cin>>n;
vector< pair<pii, pii> >v(n);
for(i=0;i<n;i++){
cin>>x1>>y1>>x2>>y2;
if(y2<y1){
swap(y2,y1);
swap(x2,x1);
}
v[i]={ {x1,y1}, {x2,y2} };
}//x1=x2 e y2>y1
if(x1==x2){//todos verticais
sort(v.begin(),v.end());
}else{
for(i=0;i<n;i++){//ver qual a y coordinate em x=0
if(v[i].first.first>v[i].second.first)swap(v[i].first,v[i].second);
}
//sort(info.begin(),info.end());
sort(v.begin(),v.end(),comp);
}
for(i=0;i<n-1;i++){
cout<<v[i].second.first<<" "<<v[i].second.second<<" ";
cout<<v[i+1].first.first<<" "<<v[i+1].first.second<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
26 ms |
3556 KB |
Execution killed with signal 11 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
324 KB |
Output is correct |
4 |
Correct |
10 ms |
1220 KB |
Output is correct |
5 |
Correct |
19 ms |
2040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
10 ms |
1188 KB |
Output is correct |
5 |
Correct |
19 ms |
2032 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
13 ms |
1156 KB |
Output is correct |
10 |
Correct |
140 ms |
9372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
324 KB |
Output is correct |
4 |
Correct |
10 ms |
1188 KB |
Output is correct |
5 |
Correct |
19 ms |
2104 KB |
Output is correct |
6 |
Failed |
1 ms |
204 KB |
Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])" |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
11 ms |
1188 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
14 ms |
1192 KB |
Output is correct |
10 |
Failed |
1 ms |
204 KB |
Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])" |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
26 ms |
3548 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |