Submission #919914

# Submission time Handle Problem Language Result Execution time Memory
919914 2024-02-01T20:36:00 Z CyberCow Roads (CEOI20_roads) C++17
30 / 100
118 ms 9952 KB
#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

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
1 Failed 1 ms 348 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 13 ms 1732 KB Output is correct
5 Correct 23 ms 2264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 12 ms 1500 KB Output is correct
5 Correct 24 ms 2256 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 12 ms 1500 KB Output is correct
10 Correct 118 ms 9952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 12 ms 1500 KB Output is correct
5 Correct 23 ms 2256 KB Output is correct
6 Failed 0 ms 348 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 0 ms 348 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 348 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -