QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#136437 | #4189. Flappy Bird | RetiredButNotTired# | WA | 1ms | 5696kb | C++17 | 1.6kb | 2023-08-08 19:12:00 | 2023-08-08 19:12:03 |
Judging History
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;
}
详细
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