Submission #791470

# Submission time Handle Problem Language Result Execution time Memory
791470 2023-07-24T06:50:51 Z PoonYaPat Roads (CEOI20_roads) C++14
15 / 100
17 ms 1876 KB
#include <bits/stdc++.h>
using namespace std;

struct point {
    int x,y;
};
typedef pair<point,point> ppp;

vector<ppp> v;
bool u;
int n;

bool comp(ppp A, ppp B) {
    point a=A.first, b=B.first;
    if (A.first.x==A.second.x) {
        if (a.x!=b.x) return a.x<b.x;
        else return a.y>b.y;
    } else if (A.first.y==A.second.y) {
        if (a.y!=b.y) return a.y<b.y;
        return a.x>b.x;
    } else if (u) {
        if (a.y-a.x!=b.y-b.x) return a.y-a.x<b.y-b.x;
        else return a.y>b.y;
    } else {
        if (a.x+a.y!=b.x+b.y) return a.x+a.y<b.x+b.y;
        else return a.y>b.y;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=0; i<n; ++i) {
        point a,b;
        cin>>a.x>>a.y>>b.x>>b.y;
        if (a.y>b.y) swap(a,b);
        if (a.y==b.y && a.x>b.x) swap(a,b);
        v.push_back(ppp(a,b));
    }
    if (v[0].first.x<v[0].second.x) u=true;
    sort(v.begin(),v.end(),comp);
    for (int i=1; i<v.size(); ++i) cout<<v[i-1].first.x<<" "<<v[i-1].first.y<<" "<<v[i].second.x<<" "<<v[i].second.y<<"\n";
}

Compilation message

roads.cpp: In function 'int main()':
roads.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<point, point> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i=1; i<v.size(); ++i) cout<<v[i-1].first.x<<" "<<v[i-1].first.y<<" "<<v[i].second.x<<" "<<v[i].second.y<<"\n";
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Failed 0 ms 212 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 316 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 7 ms 1112 KB Output is correct
5 Correct 13 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 9 ms 1228 KB Output is correct
5 Correct 17 ms 1860 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Failed 1 ms 340 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
8 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 1 ms 340 KB Output is correct
4 Correct 7 ms 1120 KB Output is correct
5 Correct 15 ms 1816 KB Output is correct
6 Failed 1 ms 316 KB Condition failed: "!Cross(S[*pi], S[*pa])"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 212 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 212 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -