QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#136437#4189. Flappy BirdRetiredButNotTired#WA 1ms5696kbC++171.6kb2023-08-08 19:12:002023-08-08 19:12:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-08 19:12:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5696kb
  • [2023-08-08 19:12:00]
  • 提交

answer

// Hey there.. I love you <3
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

mt19937 rnd(time(nullptr));

const int N = 1e6 + 5, mod = 1e9 + 7;
const double pi = acos(-1), eps = 5e-10;

struct point {
    int x, y;
    double slope(const point &other) const { return 1.0 * (y - other.y) / (x - other.x); }
};

point s, e;
point a[N], b[N];

void work() {
    
    int n;
    cin >> s.x >> s.y >> e.x >> e.y >> n;
    
    point cur = s;
    vector<point> ans = {cur};
    pair<double, double> S = {-1e10, 1e10};
    
    for (int i = 0; i < n; ++i)
        cin >> a[i].x >> a[i].y >> b[i].y, b[i].x = a[i].x;
    
    
    for (int i = 0; i < n; ++i) {
        
        pair<double, double> newS = {cur.slope(a[i]), cur.slope(b[i])};
        
        bool f = false;
        
        if (newS.first > S.second + eps)
            cur = b[i - 1], f = true;
        else if (newS.second < S.first - eps)
            cur = a[i - 1], f = true;
        
        if (f)
            ans.push_back(cur), S = {-1e10, 1e10}, --i;
        else
            S = {max(S.first, newS.first), min(S.second, newS.second)};
    }
    ans.push_back(e);
    
    for (auto it: ans) cout << it.x << " " << it.y << endl;
    
    
}


void init() {
    cin.tie(nullptr);
    istream::sync_with_stdio(false);
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    
    
}

int main() {
    init();
    
    int testCases = 1;
//    cin >> testCases;
    while (testCases--) work();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5632kb

input:

0 0 10 0
1
5 -10 10

output:

0 0
10 0

result:

ok 

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5696kb

input:

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

output:

0 0
4 2
10 0

result:

wrong answer Output doesn't match expected line