結果

問題 No.635 自然門松列
ユーザー commycommy
提出日時 2020-04-05 03:39:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,132 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 74,844 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 06:26:04
合計ジャッジ時間 1,770 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘P up(int, int, int, int)’ 内:
main.cpp:53:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   53 | }
      | ^

ソースコード

diff #

#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;
        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;
}
0