Submission #667583

# Submission time Handle Problem Language Result Execution time Memory
667583 2022-12-01T18:15:05 Z mychecksedad Roads (CEOI20_roads) C++17
15 / 100
14 ms 1620 KB
/* Author : Mychecksdead */
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD1 (1000000000+7)
#define MOD (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;

struct Point{
    ll x, y;
    Point(){};
    Point(ll a, ll b){
        x = a, y = b;
    }
};

struct Line{
    Point l, r;
    bool vertic;
    Line(){};
    Line(Point l, Point r){
        l = l, r = r;
        if(l.y < r.y) swap(l, r);
        if(l.x == r.x){
            vertic = 1;
        }else vertic = 0;
    }
    void check(){
        if(l.y < r.y) swap(l, r);
        if(l.x == r.x){
            vertic = 1;
        }else vertic = 0;
    }
    bool operator<(Line &other) const{
        if(other.l.x != l.x){
            return other.l.x > l.x;
        }
        return other.l.y > l.y;
    }
    bool is(Line &other){
        if(vertic | other.vertic){
            return (vertic & other.vertic);
        }
        if(l.x == other.r.x) return 0;
        bool ok = 1;

        double m = (l.y - r.y) / (l.x - r.x);
        double m1 = (l.y - other.r.y) / (l.x - other.r.x);

        ok &= m == m1;

        return ok;
    }
};

int n;
Line p[N];
void solve(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> p[i].l.x >> p[i].l.y;
        cin >> p[i].r.x >> p[i].r.y;
        p[i].check();
    }
    sort(p, p + n);
    for(int i = 0; i < n - 1; ++i){
        if(!p[i].is(p[i + 1])){
            cout << p[i].l.x << ' ' << p[i].l.y << ' ' << p[i + 1].l.x << ' ' << p[i + 1].l.y << '\n';
        }else{
            if(p[i].vertic)
                cout << p[i].l.x << ' ' << p[i].l.y << ' ' << p[i + 1].r.x << ' ' << p[i + 1].r.y << '\n';
            else{
                Point a, b;
                if(p[i].l.x > p[i].r.x) a = p[i].l;
                else a = p[i].r;

                 if(p[i + 1].l.x < p[i + 1].r.x) b = p[i + 1].l;
                else b = p[i + 1].r;

                cout << a.x << ' ' << a.y << ' ' << b.x << ' ' << b.y << '\n';
            }
        }
    }
}




int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int T = 1, aa;
    // cin >> T;aa=T;
    while(T--){
        // cout << "Case #" << aa-T << ": ";
        solve();
        cout << '\n';
    }
    return 0;
 
}

Compilation message

roads.cpp: In function 'int main()':
roads.cpp:99:16: warning: unused variable 'aa' [-Wunused-variable]
   99 |     int T = 1, aa;
      |                ^~
# Verdict Execution time Memory Grader output
1 Failed 0 ms 212 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 7 ms 980 KB Output is correct
5 Correct 14 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 8 ms 1024 KB Output is correct
5 Correct 13 ms 1620 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Failed 1 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 368 KB Output is correct
4 Correct 8 ms 980 KB Output is correct
5 Correct 14 ms 1612 KB Output is correct
6 Failed 0 ms 212 KB Condition failed: "!Cross(S[*pi], S[*pa])"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 212 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 212 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -