This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <random>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((x).size())
typedef long long ll;
using namespace std;
mt19937 rnd(348502);
const ll N = 2010;
ll mod = 1e9 + 7;
double m, eps;
bool xD(const pair<pair<double, double>, pair<double, double>>& a, const pair<pair<double, double>, pair<double, double>>& b)
{
if (m == 1e9)
{
if (a.first.first == b.first.first)
{
return a.first.second < b.first.second;
}
return a.first.first < b.first.first;
}
if (abs((a.first.second - m * a.first.first) - (b.first.second - m * b.first.first)) <= eps)
{
return a.second.second < b.second.second;
}
return a.first.second - m * a.first.first < b.first.second - m * b.first.first;
}
void solve()
{
double n, i, j, x, y, x1, y1;
eps = double(1) / double(1000000);
cin >> n;
vector<pair<pair<ll, ll>, pair<ll, ll>>> v;
for (i = 0; i < n; i++)
{
cin >> x >> y >> x1 >> y1;
if (y <= y1)
v.push_back({ {x, y},{x1, y1} });
else
v.push_back({ {x1, y1},{x, y} });
}
if (x1 - x != 0)
m = (y1 - y) / (x1 - x);
else
m = 1e9;
sort(all(v), xD);
for (i = 0; i < n - 1; i++)
{
cout << v[i].second.first << ' ' << v[i].second.second << ' ' << v[i + 1].first.first << ' ' << v[i + 1].first.second << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
ll tt = 1;
//cout << (mod + -10000010 % mod) % mod;
//cin >> tt;
while (tt--) {
solve();
}
return 0;
}
Compilation message (stderr)
roads.cpp: In function 'void solve()':
roads.cpp:49:18: warning: unused variable 'j' [-Wunused-variable]
49 | double n, i, j, x, y, x1, y1;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |