Submission #412958

#TimeUsernameProblemLanguageResultExecution timeMemory
412958PbezzRoads (CEOI20_roads)C++14
15 / 100
108 ms12388 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 = v.first.first; y1 = v.first.second; x2 = v.second.first; y2 = v.second.second; y2-=y1; x2-=x1; x1 = x1*(y2)/x2; return 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 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 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...