結果

問題 No.635 自然門松列
ユーザー pekempeypekempey
提出日時 2018-01-19 21:50:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 650 ms
コード長 1,037 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 73,080 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 13:07:41
合計ジャッジ時間 1,623 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

using namespace std;

const double eps = 1e-8;

bool is_kadomatsu(double x, double y, double z) {
  if (abs(x - y) < eps) return false;
  if (abs(x - z) < eps) return false;
  if (abs(y - z) < eps) return false;
  return (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]);
          cand.push_back(c - 1e-6);
          cand.push_back(c + 1e-6);
        }
      }
    }

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