Submission #791398

# Submission time Handle Problem Language Result Execution time Memory
791398 2023-07-24T05:57:16 Z ttamx Roads (CEOI20_roads) C++14
0 / 100
1 ms 316 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=1e5+5;
const ld eps=1e-9;

struct point{
    ll x,y;
    point():x(0),y(0){}
    point(ll x,ll y):x(x),y(y){}
    const bool operator<(const point &o)const{
        if(y==o.y)return x<o.x;
        return y<o.y;
    }
};

struct line{
    point p1,p2;
    line(point p1,point p2):p1(min(p1,p2)),p2(max(p1,p2)){}
    line(ll x1,ll y1,ll x2,ll y2){
        *this=line(point(x1,y1),point(x2,y2));
    }
    const ll dx()const{
        return p1.x-p2.x;
    }
    const ll dy()const{
        return p1.y-p2.y;
    }
    const ld m()const{
        return 1.0*dy()/dx();
    }
    const ld c()const{
        return p1.y-m()*p1.x;
    }
    const bool operator<(const line &o)const{
        ld a=c(),b=o.c();
        if(abs(a-b)<eps)return p1<o.p1;
        return a<b;
    }
};

int n;
vector<line> vec;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n;
    for(int i=1;i<=n;i++){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        vec.emplace_back(line(a,b,c,d));
    }
    sort(vec.begin(),vec.end());
    for(int i=1;i<n;i++){
        cout << vec[i-1].p2.x << " " << vec[i-1].p2.y << " " << vec[i].p1.x << " " << vec[i].p2.y << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Failed 1 ms 212 KB Condition failed: "iA != P2I.end()"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 212 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 212 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 316 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 212 KB Condition failed: "iA != P2I.end()"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 316 KB Condition failed: "iA != P2I.end()"
2 Halted 0 ms 0 KB -