Submission #1037989

#TimeUsernameProblemLanguageResultExecution timeMemory
1037989vjudge1Roads (CEOI20_roads)C++17
30 / 100
76 ms9664 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ar array #define ld long double const int N = 2e5 + 20; const int INF = 1e15; const int MOD = 1e9 + 7; const ld EPS = 1e-9; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt") struct Line{ ar<int, 2> a, b; Line(int x, int y, int z, int w){ a = {x, y}, b = {z, w}; } double get(){ if(a[0] == b[0])return -a[0]; return a[1] - a[0] * (1.0 * b[1] - a[1]) / (b[0] - a[0]); } }; bool comp(Line a, Line b){ if(abs(a.get() - b.get()) >= EPS)return a.get() > b.get(); return a.a < b.a; } signed main(){ios_base::sync_with_stdio(false);cin.tie(0); int n; cin>>n; vector<Line> A; for(int i = 0;i < n;i++){ int x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2; if(x1 == x2){ if(y1 > y2)swap(y1, y2), swap(x1, x2); }else if(x1 > x2)swap(x1, x2), swap(y1, y2); A.push_back(Line{x1, y1, x2, y2}); } sort(A.begin(), A.end(), comp); for(int i = 1;i < n;i++)cout<<A[i - 1].b[0]<<" "<<A[i-1].b[1]<<" "<<A[i].a[0]<<" "<<A[i].a[1]<<'\n'; }
#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...