結果
| 問題 |
No.635 自然門松列
|
| コンテスト | |
| ユーザー |
はむこ
|
| 提出日時 | 2017-07-07 08:34:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 650 ms |
| コード長 | 1,709 bytes |
| コンパイル時間 | 1,422 ms |
| コンパイル使用メモリ | 161,952 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 08:46:16 |
| 合計ジャッジ時間 | 2,142 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 23 |
ソースコード
#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;
}
はむこ