結果

問題 No.635 自然門松列
ユーザー pekempeypekempey
提出日時 2018-01-19 21:48:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 72,448 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-26 00:14:23
合計ジャッジ時間 1,684 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

bool is_kadomatsu(double x, double y, double z) {
  return x != y && x != z && y != z && (x < y && y > z || x > y && y < z);
}

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


  while (T--) {
    double x[3];
    double y[3];

    for (int i = 0; i < 3; i++) cin >> x[i];
    for (int i = 0; i < 3; i++) cin >> y[i];

    vector<double> cand;
    cand.push_back(0);
    cand.push_back(12312312);

    // x[i]+y[i]*k == x[j]+y[j]*k
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (y[j] != y[i]) {
          double c = (x[i] - x[j]) / (y[j] - y[i]);
          if (c >= 1e-6) {
            cand.push_back(c - 1e-6);
          }
          cand.push_back(c + 1e-6);
        }
      }
    }

    bool ok = false;
    for (double c : cand) {
      ok |= is_kadomatsu(x[0] + y[0] * c, x[1] + y[1] * c, x[2] + y[2] * c);
    }
    puts(ok ? "YES" : "NO");
  }
}
0