結果
| 問題 |
No.2594 Mix shake!!
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2023-12-11 22:58:38 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,466 bytes |
| コンパイル時間 | 2,002 ms |
| コンパイル使用メモリ | 132,684 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-27 09:06:15 |
| 合計ジャッジ時間 | 4,087 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 68 WA * 17 |
ソースコード
// C++, WA (double)
#include <algorithm>
#include <iostream>
#include <numeric>
#include <tuple>
#include <vector>
using namespace std;
using Float = double;
auto make_convex_slope(const vector<long long> &A, const vector<long long> &B) {
long long x = 0, y = 0;
vector<pair<long long, long long>> ret{{0, 0}};
vector<tuple<Float, long long, long long>> seq;
for (int i = 0; i < (int)A.size(); ++i) seq.emplace_back(Float(B[i]) / A[i], A[i], B[i]);
sort(seq.begin(), seq.end());
for (const auto &[_, a, b] : seq) {
x += a;
y += b;
ret.emplace_back(x, y);
}
return ret;
}
bool float_fake_solve(const vector<long long> &A, const vector<long long> &B, const vector<long long> &C, const vector<long long> &D) {
const int n = A.size();
vector<pair<Float, int>> AB, CD;
for (int i = 0; i < n; ++i) {
AB.emplace_back(Float(B.at(i)) / A.at(i), i);
CD.emplace_back(Float(D.at(i)) / C.at(i), i);
}
sort(AB.begin(), AB.end());
sort(CD.begin(), CD.end());
auto lb_xys = make_convex_slope(A, B);
auto ub_xys = make_convex_slope(C, D);
for (int i = 0; i < (int)lb_xys.size() - 1; ++i) {
auto [x0, y0] = lb_xys.at(i);
auto [x1, y1] = lb_xys.at(i + 1);
for (const auto &[x, y] : ub_xys) {
if ((__int128)(x1 - x0) * (y - y0) - (__int128)(y1 - y0) * (x - x0) < 0) return false;
}
}
vector<int> ab_indices, cd_indices;
for (const auto &[_, i] : AB) ab_indices.push_back(i);
for (const auto &[_, i] : CD) cd_indices.push_back(i);
if (ab_indices == cd_indices) return true;
Float vx = 0, vy = 0;
for (int i = 0; i < n - 1; ++i) {
auto [px, py] = ub_xys.at(i + 1);
if (px <= vx) return true;
Float a1 = (py - vy) / (px - vx);
Float b1 = vy - a1 * vx;
auto [ax, ay] = lb_xys[i + 1];
auto [bx, by] = lb_xys[i + 2];
Float a2 = Float(by - ay) / (bx - ax);
Float b2 = ay - a2 * ax;
if (a1 >= a2) return true;
vx = (b2 - b1) / (a1 - a2);
vy = a1 * vx + b1;
if (vx >= bx) return true;
}
return false;
}
int main() {
int n;
cin >> n;
vector<long long> A(n), B(n), C(n), D(n);
for (auto &a : A) cin >> a;
for (auto &b : B) cin >> b;
for (auto &c : C) cin >> c;
for (auto &d : D) cin >> d;
cout << (float_fake_solve(A, B, C, D) ? "Yes" : "No") << '\n';
}
hitonanode