結果

問題 No.635 自然門松列
ユーザー はむこはむこ
提出日時 2017-07-07 08:34:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 650 ms
コード長 1,709 bytes
コンパイル時間 2,618 ms
コンパイル使用メモリ 148,332 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-05 13:06:56
合計ジャッジ時間 2,352 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
using ll = long long; 

using vd = vector<double>;
bool is_k(vd x) {
    if (x[0] == x[1]) return false;
    if (x[1] == x[2]) return false;
    if (x[2] == x[0]) return false;
    if (x[0] <= x[1] && x[1] <= x[2]) return false;
    if (x[0] >= x[1] && x[1] >= x[2]) return false;
    return true;
}
ll sgn(double x) {
    if (x > 0) 
        return 1;
    if (x < 0) 
        return -1;
    else
        return 0;
}
bool eq(double x, double y) {
    return abs(x - y) < 1e-10;
}

#define RET_YES cout << "YES" << endl; continue;
#define RET_NO cout << "NO" << endl; continue;
int main(void) {
    ll _; cin >> _;
    rep(__, _) {
        vd x(3), y(3); cin >> x[0] >> x[1] >> x[2] >> y[0] >> y[1] >> y[2];
        if (is_k(x)) { RET_YES; }
        if (is_k(y)) { RET_YES; }
        if (y[0] == y[1] && y[1] == y[2]) { RET_NO; }
        if (x[0] == x[2]) {
            if (x[0] == x[1]) {
                RET_NO;
            } else if (y[0] == y[2]) {
                RET_NO; 
            } else {
                RET_YES; 
            }
        } else {
            if (y[0] == y[2]) {
                RET_YES;
            } else if (sgn(x[0] - x[2]) == sgn(y[0] - y[2])) {
                RET_NO; 
            } else {
                if (x[0] < x[2]) 
                    swap(x[0], x[2]), swap(y[0], y[2]);
                double t = -(x[2] - x[0]) / (y[2] - y[0]);
                if (eq(x[0] + t * y[0], x[1] + t * y[1])) {
                    RET_NO; 
                } else {
                    RET_YES; 
                }
            }
        }
    }
    return 0;
}
0