結果

問題 No.3005 トレミーの問題
ユーザー ont
提出日時 2025-09-03 00:06:15
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 3,166 bytes
コンパイル時間 5,383 ms
コンパイル使用メモリ 336,088 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-03 00:06:23
合計ジャッジ時間 7,387 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pq_g = priority_queue<T, vector<T>, greater<T>>;
using mint = modint998244353;
// using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define unique(v) (v).erase(unique(all(v)), (v).end())
#define NP next_permutation
#define endl "\n"
#define debug(x) cerr << #x << " = " << (x) << endl
const int INF = 2e9;
const ll LINF = 2e18;
void Yes(bool a) {cout << (a ? "Yes" : "No") << endl;}
void YES(bool a) {cout << (a ? "YES" : "NO") << endl;}
void Possible(bool a) {cout << (a ? "Possible" : "Impossible") << endl;}
void POSSIBLE(bool a) {cout << (a ? "POSSIBLE" : "IMPOSSIBLE") << endl;}
ll modPow(ll a, ll n, ll mod = LINF) {ll ret = 1; ll x = a % mod; while (n) {if (n & 1) ret = ret * x % mod; x = x * x % mod; n >>= 1;} return ret;}
template<typename T> T floor(T a, T b) {return a / b - (a % b && (a ^ b) < 0);}
template<typename T> T ceil(T a, T b) {return floor(a + b - 1, b);}
template<typename T> void vcin(vector<T> &a) {rep(i, int(a.size())) cin >> a[i];}
template<typename T, typename K> void vcin(vector<T> &a, vector<K> &b) {rep(i, int(a.size())) cin >> a[i] >> b[i];}
template<typename T> void vcout(vector<T> &a) {rep(i, int(a.size())) {cout << a[i] << " ";} cout << endl;}
template<typename T> void vcin(vector<vector<T>> &a) {rep(i, int(a.size())) rep(j, (int)a[i].size()) cin >> a[i][j];}
template<typename T> void vcout(vector<vector<T>> &a) {rep(i, int(a.size())) {rep(j, int(a[i].size())) {cout << a[i][j] << " ";} cout << endl;} cout << endl;}
template<typename T> auto vmin(vector<T> &a) {return *min_element(all(a));}
template<typename T> auto vmax(vector<T> &a) {return *max_element(all(a));}
template<typename T> auto vsum(vector<T> a) {return accumulate(all(a), T(0));}
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;}

void cincout() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
}
 
bool solve(ll a, ll b, ll c) {
    ll x = sqrtl(a * b);
    return x * x == a * b && a + b + 2 * x == c;
}

int main() {
    cincout();

    vector<ll> X(4), Y(4);
    vcin(X, Y);

    vector<int> P(4);
    iota(all(P), 0);

    auto f = [&](int i, int j) {
        return (X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]);
    };

    auto g = [&](int i, int j, int k) {
        return (Y[j] - Y[i]) * (X[k] - X[j]) == (Y[k] - Y[j]) * (X[j] - X[i]);
    };

    do {
        bool ok = true;
        for (int i = 0; i < 4; i++) if (g(i, (i + 1) % 4, (i + 2) % 4)) ok = false;
        if (ok && solve(f(P[0], P[1]) * f(P[2], P[3]), f(P[0], P[3]) * f(P[1], P[2]), f(P[0], P[2]) * f(P[1], P[3]))) {
            cout << "YES" << endl;
            return 0;
        }
    } while (NP(all(P)));

    YES(0);
}
0