QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#419298#4189. Flappy Birdgo_nextWA 0ms3636kbC++202.0kb2024-05-23 20:05:482024-05-23 20:05:51

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 20:05:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-05-23 20:05:48]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;


struct point {
    long long x, y;

    bool operator<(point other) const {
        return (1LL * x * other.y < 1LL * other.x * y);
    }

    bool operator>(point other) const {
        return (1LL * x * other.y > 1LL * other.x * y);
    }

    void reduce() {
        long long g = __gcd(x, y);
        x /= g;
        y /= g;
    }
};

point slope(point p1, point p2) {
//    cerr << p1.x << ' ' << p1.y << ' ' << p2.x << ' ' << p2.y << '\n';
    point ret;
    ret.x = p2.y - p1.y;
    ret.y = p2.x - p1.x;
    ret.reduce();
//    cerr << ret.x << ' ' << ret.y << '\n';
    return ret;
}

const int N = 1e6 + 5;
pair<point, point> a[N];

void tc() {
    int n;
    cin >> a[0].first.x >> a[0].first.y;
    a[0].second = a[0].first;
    int tex, tey;
    cin >> tex >> tey;
    cin >> n;
    a[n + 1].second = a[n + 1].first = {tex, tey};
    for (int i = 1; i <= n; i++) {
        int x, y1, y2;
        cin >> x >> y1 >> y2;
        a[i].first = {x, y1};
        a[i].second = {x, y2};
    }

    point cur = a[0].first;
    cout << cur.x << ' ' << cur.y << '\n';
    point l = {-INT_MAX , 1}, r = {INT_MAX, 1};
    for (int i = 1; i <= n + 1; i++) {
        point s1 = slope(cur, a[i].first);
        point s2 = slope(cur, a[i].second);
        if (s1 > r) {

            cur = a[i - 1].second;

            l = {-INT_MAX, 1}, r = {INT_MAX, 1};

            cout << cur.x << ' ' << cur.y << '\n';
        } else if (s2 < l) {
            cur = a[i - 1].first;


            l = {-INT_MAX, 1}, r = {INT_MAX, 1};

            cout << cur.x << ' ' << cur.y << '\n';
        } else {
            l = max(l, s1);
            r = min(r, s2);
        }
    }

    cout << tex << ' ' << tey << '\n';
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;

//    cin >> t;

    while (t--) {
        tc();
    }

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3636kb

input:

0 0 10 0
1
5 -10 10

output:

0 0
10 0

result:

ok 

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3548kb

input:

0 0 10 0
4
2 1 3
4 2 3
7 0 2
9 -2 -1

output:

0 0
4 2
7 0
10 0

result:

wrong answer Output doesn't match expected line