結果
| 問題 |
No.635 自然門松列
|
| コンテスト | |
| ユーザー |
commy
|
| 提出日時 | 2020-04-05 03:44:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 650 ms |
| コード長 | 3,234 bytes |
| コンパイル時間 | 600 ms |
| コンパイル使用メモリ | 75,492 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 07:58:25 |
| 合計ジャッジ時間 | 1,449 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function 'P up(int, int, int, int)':
main.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
53 | }
| ^
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<double, double>;
// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on
const ll inf = 1LL << 60;
double eps = 1e-8;
P up(int x1, int x2, int y1, int y2) {
if (x1 < x2 && y1 <= y2) {
return P(0, inf);
}
if (x1 < x2 && y1 > y2) {
return P(0, double(x2 - x1) / (y1 - y2));
}
if (x1 > x2 && y1 < y2) {
return P(double(x1 - x2) / (y2 - y1), inf);
}
if (x1 > x2 && y1 >= y2) {
return P(inf, 0);
}
if (x1 == x2 && y1 < y2) {
return P(eps * 10, inf);
}
if (x1 == x2 && y1 >= y2) {
return P(inf, 0);
}
}
bool isSame(int x1, int x2, int x3, int y1, int y2, int y3, double m) {
double a = x1 + y1 * m, b = x2 + y2 * m, c = x3 + y3 * m;
dump(m, a, b, c);
return abs(a - b) < eps || abs(a - c) < eps || abs(b - c) < eps;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int T;
cin, T;
REP(i, 0, T) {
int x1, x2, x3, y1, y2, y3;
cin, x1, x2, x3, y1, y2, y3;
if (x1 == x3 && y1 == y3) {
cout << "NO" << endl;
continue;
}
P p1 = up(x1, x2, y1, y2), p2 = up(-x2, -x3, -y2, -y3);
P p3 = up(-x1, -x2, -y1, -y2), p4 = up(x2, x3, y2, y3);
dump(p1.first, p1.second);
dump(p2.first, p2.second);
dump(p3.first, p3.second);
dump(p4.first, p4.second);
chmax(p1.first, p2.first);
chmin(p1.second, p2.second);
chmax(p3.first, p4.first);
chmin(p3.second, p4.second);
if (p1.first - eps <= p1.second) {
if (abs(p1.first - p1.second) >= eps || !isSame(x1, x2, x3, y1, y2, y3, p1.first)) {
cout << "YES" << endl;
continue;
}
}
if (p3.first - eps <= p3.second) {
if (abs(p3.first - p3.second) >= eps || !isSame(x1, x2, x3, y1, y2, y3, p3.first)) {
cout << "YES" << endl;
continue;
}
}
cout << "NO" << endl;
}
return 0;
}
commy