# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
412968 |
2021-05-27T21:24:31 Z |
Pbezz |
Roads (CEOI20_roads) |
C++14 |
|
109 ms |
9464 KB |
#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);
}
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());
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';
}
}else{
long double k;
vector< pair<long double, pii>>info(n);
//info[i] = { Y ,{ X, I } };
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);
k = value(v[i]);
//cout<<i<<" "<<k<<endl;
info[i] = { k ,{ v[i].first.first, i } };
}
sort(info.begin(),info.end());
for(i=0;i<n-1;i++){
cout<<v[ info[i].second.second ].second.first<<" "<<v[info[i].second.second ].second.second<<" ";
cout<<v[ info[i+1].second.second ].first.first<<" "<<v[info[i+1].second.second ].first.second<<'\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
1 ms |
204 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
11 ms |
836 KB |
Output is correct |
5 |
Correct |
25 ms |
1548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
10 ms |
896 KB |
Output is correct |
5 |
Correct |
19 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
11 ms |
1228 KB |
Output is correct |
10 |
Failed |
109 ms |
9464 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
10 ms |
844 KB |
Output is correct |
5 |
Correct |
21 ms |
1484 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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
1 ms |
204 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
1 ms |
204 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |