結果

問題 No.635 自然門松列
ユーザー maimai
提出日時 2017-04-09 01:32:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,687 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 165,840 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 12:57:08
合計ジャッジ時間 2,690 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 AC 3 ms
4,372 KB
testcase_06 AC 3 ms
4,368 KB
testcase_07 AC 3 ms
4,368 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 2 ms
4,368 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 1 ms
4,368 KB
testcase_16 WA -
testcase_17 AC 3 ms
4,368 KB
testcase_18 AC 2 ms
4,372 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 3 ms
4,368 KB
testcase_23 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#ifdef WINT_MIN
#define __MAI
#endif

using namespace std;
typedef long long int ll;


// 門松列の判定
inline bool kadomatu(float a, float b, float c) {
    return a != b&&b != c&&c != a && ((a<b && c<b) || (a>b && c>b));
}


bool solve(float x1, float x2, float x3, float y1, float y2, float y3) {

    // 時間0で🎍
    if (kadomatu(x1, x2, x3)) return true;
    // 十分な時間経過で🎍
    if (kadomatu(y1, y2, y3)) return true;


    // 二分探索する.
    // tL = 0, tH = (大きな数値)から開始する.
    // tLのときに竹の長さが昇順だったとすると,tHは降順になっているはずである.
    // どこかで昇順と降順が切り替わっているはずなので,その時刻を探し,🎍になっているかどうか検証する.

    float tl = 0.0;
    float th = 1e9;
    float tc;

    for (int i = 0; i < 80; ++i) {
        tc = (tl + th) / 2;

        // 時刻tcで🎍かどうか調べる
        if (kadomatu(x1 + y1*tc, x2 + y2*tc, x3 + y3*tc)) {
            return true;
        }

        // 時刻0の『昇順,降順』と時刻tcの『昇順,降順』が等しいなら
        if ((x1 < x3) == (x1 + y1*tc < x3 + y3*tc)) {
            tl = tc;
        }
        else {
            th = tc;
        }

    }
    return false;
}


int main() {
    int n;
    float x1, x2, x3, y1, y2, y3;

    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> x1 >> x2 >> x3 >> y1 >> y2 >> y3;
        
        if (solve(x1, x2, x3, y1, y2, y3)) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }


    return 0;
}
0