Submission #413528

#TimeUsernameProblemLanguageResultExecution timeMemory
413528PbezzRoads (CEOI20_roads)C++14
30 / 100
140 ms9372 KiB
#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; }
#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...