제출 #791572

#제출 시각아이디문제언어결과실행 시간메모리
791572petezaRoads (CEOI20_roads)C++14
15 / 100
36 ms1288 KiB
#include <bits/stdc++.h>
using namespace std;

int n, xx1, yy1, xx2, yy2;
using pii = pair<int, int>;
struct line {
    pii a, b;
    line(int ax, int ay, int bx, int by){a={ax,ay};b={bx,by};}
    double gety() {
        if(a.first == b.first) return -a.first;
        return a.second - (1.00*b.second-a.second)/(b.first-a.first);
    }
};

vector<line> lns;

ostream& operator<<(ostream& os, pii a) {
    os << a.first << ' ' << a.second;
    return os;
}

int main() {
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> xx1 >> yy1 >> xx2 >> yy2;
        if(xx1 == xx2) {
            if(yy1 > yy2) swap(yy1, yy2);
        } else {
            if(xx1 > xx2) swap(xx1, xx2);
        }
        lns.emplace_back(xx1, yy1, xx2, yy2);
    }
    sort(lns.begin(), lns.end(), [](line a, line b){
        if(a.gety() != b.gety()) return a.gety() > b.gety();
        return a.a < b.b;
    });
    for(int i=1;i<lns.size();i++) cout << lns[i-1].b << ' ' << lns[i].a << '\n';
}

컴파일 시 표준 에러 (stderr) 메시지

roads.cpp: In function 'int main()':
roads.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<line>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=1;i<lns.size();i++) cout << lns[i-1].b << ' ' << lns[i].a << '\n';
      |                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...