답안 #963092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963092 2024-04-14T13:55:09 Z anton Roads (CEOI20_roads) C++17
15 / 100
49 ms 5816 KB
#include<bits/stdc++.h>

using namespace std;

struct Point{
    int x, y;
    int name;

};
Point rot90(Point a){
    Point res;
    res.y= a.x;
    res.x =-a.y;
    return res;
}
Point dif(Point& a, Point& b){
    Point res;
    res.x= b.x-a.x;
    res.y = b.y-a.y;
    return res;
}
int dot(Point& a, Point& b){
    return a.x*b.x+ a.y*b.y;
}

void transform(Point& p, pair<Point, Point> base){
    int x= dot(p, base.first);
    int y= dot(p, base.second);
    p.x =x;
    p.y = y;
}
const int MAX_N = 1e5;
pair<Point, Point> pts[MAX_N];
Point initial[2*MAX_N];
signed main(){
    int n;
    cin>>n;
    for(int i = 0; i<n; i++){
        Point a, b;
        a.name = i*2;
        b.name = i*2+1;
        cin>>a.x>>a.y>>b.x>>b.y;
        initial[i*2] =a;
        initial[i*2+1] = b;
        pts[i].first= a;
        pts[i].second= b;
        
    }
    pair<Point, Point> base =  { rot90(dif(pts[0].first, pts[0].second)), dif(pts[0].first, pts[0].second)};

    for(int i= 0; i<n; i++){
        transform(pts[i].first, base);
        transform(pts[i].second, base);
        //cout<<pts[i].first.x<<" "<<pts[i].first.y<<" "<<pts[i].second.x<<" "<<pts[i].second.y<<endl;
        if(pts[i].first.y>pts[i].second.y){
            swap(pts[i].first, pts[i].second);
        }
    }
    auto cmp =[&](pair<Point, Point>& a, pair<Point, Point>& b){
        if(a.first.x!=b.first.x){
            return a.first.x<b.first.x;
        }
        else{
            return a.first.y< b.first.y;
        }
    };
    sort(&pts[0], &pts[n], cmp);

    for(int i = 0; i<n-1; i++){
        Point a= initial[pts[i].second.name];       
        Point b= initial[pts[i+1].first.name];

        cout<<a.x<<" "<<a.y<<" "<<b.x<<" "<<b.y<<endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Failed 2 ms 2396 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 4 ms 2392 KB Output is correct
4 Correct 25 ms 5212 KB Output is correct
5 Correct 49 ms 5776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 3 ms 2392 KB Output is correct
4 Correct 24 ms 5212 KB Output is correct
5 Correct 47 ms 5712 KB Output is correct
6 Correct 1 ms 2492 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Failed 4 ms 2396 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2660 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 3 ms 2396 KB Output is correct
4 Correct 30 ms 5240 KB Output is correct
5 Correct 47 ms 5816 KB Output is correct
6 Failed 1 ms 2396 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 1 ms 2392 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 1 ms 2648 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -