結果

問題 No.2594 Mix shake!!
ユーザー 👑 hitonanodehitonanode
提出日時 2023-12-08 03:14:39
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,462 bytes
コンパイル時間 1,353 ms
コンパイル使用メモリ 125,224 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-20 01:04:51
合計ジャッジ時間 3,343 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 14 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 1 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 1 ms
6,676 KB
testcase_29 WA -
testcase_30 AC 2 ms
6,676 KB
testcase_31 WA -
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 1 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 WA -
testcase_38 AC 2 ms
6,676 KB
testcase_39 AC 1 ms
6,676 KB
testcase_40 AC 2 ms
6,676 KB
testcase_41 AC 2 ms
6,676 KB
testcase_42 AC 2 ms
6,676 KB
testcase_43 AC 2 ms
6,676 KB
testcase_44 AC 2 ms
6,676 KB
testcase_45 AC 2 ms
6,676 KB
testcase_46 AC 2 ms
6,676 KB
testcase_47 AC 1 ms
6,676 KB
testcase_48 WA -
testcase_49 AC 1 ms
6,676 KB
testcase_50 AC 2 ms
6,676 KB
testcase_51 AC 2 ms
6,676 KB
testcase_52 AC 1 ms
6,676 KB
testcase_53 AC 2 ms
6,676 KB
testcase_54 AC 2 ms
6,676 KB
testcase_55 AC 2 ms
6,676 KB
testcase_56 AC 1 ms
6,676 KB
testcase_57 AC 2 ms
6,676 KB
testcase_58 AC 2 ms
6,676 KB
testcase_59 AC 1 ms
6,676 KB
testcase_60 AC 2 ms
6,676 KB
testcase_61 AC 1 ms
6,676 KB
testcase_62 AC 2 ms
6,676 KB
testcase_63 AC 1 ms
6,676 KB
testcase_64 AC 2 ms
6,676 KB
testcase_65 AC 1 ms
6,676 KB
testcase_66 AC 2 ms
6,676 KB
testcase_67 AC 2 ms
6,676 KB
testcase_68 AC 2 ms
6,676 KB
testcase_69 AC 2 ms
6,676 KB
testcase_70 AC 2 ms
6,676 KB
testcase_71 AC 1 ms
6,676 KB
testcase_72 AC 2 ms
6,676 KB
testcase_73 AC 2 ms
6,676 KB
testcase_74 AC 2 ms
6,676 KB
testcase_75 AC 1 ms
6,676 KB
testcase_76 AC 2 ms
6,676 KB
testcase_77 AC 2 ms
6,676 KB
testcase_78 AC 1 ms
6,676 KB
testcase_79 AC 2 ms
6,676 KB
testcase_80 AC 1 ms
6,676 KB
testcase_81 AC 1 ms
6,676 KB
testcase_82 AC 1 ms
6,676 KB
testcase_83 AC 2 ms
6,676 KB
testcase_84 AC 2 ms
6,676 KB
testcase_85 AC 1 ms
6,676 KB
testcase_86 AC 1 ms
6,676 KB
testcase_87 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// C++, WA
#include <algorithm>
#include <iostream>
#include <numeric>
#include <tuple>
#include <vector>

using namespace std;

using Float = long 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';
}
0