結果

問題 No.635 自然門松列
ユーザー merom686merom686
提出日時 2018-01-19 22:44:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 650 ms
コード長 1,244 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 73,360 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 13:09:09
合計ジャッジ時間 1,620 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

bool foo(int x[3], int y[3]) {
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < i; j++)
            if (y[i] == y[j] && x[i] == x[j]) return false;
    if (y[1] > y[0] && y[1] > y[2]) return true;
    if (x[1] > x[0] && x[1] > x[2]) return true;
    for (int i = 0; i < 3; i += 2)
        if (x[1] <= x[i] && y[1] <= y[i]) return false;
    if (y[1] <= y[0] && y[1] <= y[2]) return false;
    if (y[1] > y[2]) {
        swap(x[0], x[2]);
        swap(y[0], y[2]);
    }

    return (x[0] - x[1]) * (y[1] - y[2]) > (x[2] - x[1]) * (y[1] - y[0]);
}

bool is_kadomatsu(int x[3], int y[3]) {
    if (foo(x, y)) return true;
    for (int j = 0; j < 3; j++) {
        x[j] *= -1;
        y[j] *= -1;
    }
    if (foo(x, y)) return true;
    return false;
}

int main() {
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int x[3], y[3];
        for (int j = 0; j < 3; j++) {
            cin >> x[j];
        }
        for (int j = 0; j < 3; j++) {
            cin >> y[j];
        }

        cout << (is_kadomatsu(x, y) ? "YES" : "NO") << endl;
    }

    return 0;
}
0