結果
| 問題 |
No.635 自然門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-09 01:32:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,700 bytes |
| コンパイル時間 | 1,493 ms |
| コンパイル使用メモリ | 167,692 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 11:43:36 |
| 合計ジャッジ時間 | 2,316 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 21 WA * 2 |
ソースコード
#include "bits/stdc++.h"
#ifdef WINT_MIN
#define __MAI
#endif
using namespace std;
typedef long long int ll;
// 門松列の判定
inline bool kadomatu(double a, double b, double c) {
return a != b&&b != c&&c != a && ((a<b && c<b) || (a>b && c>b));
}
bool solve(double x1, double x2, double x3, double y1, double y2, double y3) {
// 時間0で🎍
if (kadomatu(x1, x2, x3)) return true;
// 十分な時間経過で🎍
if (kadomatu(y1, y2, y3)) return true;
// 二分探索する.
// tL = 0, tH = (大きな数値)から開始する.
// tLのときに竹の長さが昇順だったとすると,tHは降順になっているはずである.
// どこかで昇順と降順が切り替わっているはずなので,その時刻を探し,🎍になっているかどうか検証する.
double tl = 0.0;
double th = 1e9;
double tc;
for (int i = 0; i < 80; ++i) {
tc = (tl + th) / 2;
// 時刻tcで🎍かどうか調べる
if (kadomatu(x1 + y1*tc, x2 + y2*tc, x3 + y3*tc)) {
return true;
}
// 時刻0の『昇順,降順』と時刻tcの『昇順,降順』が等しいなら
if ((x1 < x3) == (x1 + y1*tc < x3 + y3*tc)) {
tl = tc;
}
else {
th = tc;
}
}
return false;
}
int main() {
int n;
double x1, x2, x3, y1, y2, y3;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> x1 >> x2 >> x3 >> y1 >> y2 >> y3;
if (solve(x1, x2, x3, y1, y2, y3)) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
return 0;
}