結果
問題 |
No.3005 トレミーの問題
|
ユーザー |
![]() |
提出日時 | 2025-01-18 16:21:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,601 bytes |
コンパイル時間 | 6,379 ms |
コンパイル使用メモリ | 251,784 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-18 16:21:35 |
合計ジャッジ時間 | 5,248 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair<ll,ll>; using lb = long double; using T = tuple<ll, ll, ll>; #ifdef LOCAL # include <debug_print.hpp> # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast<void>(0)) #endif int main() { vector<pair<int,int>> pos(4); rep(i,4) cin >> pos[i].first >> pos[i].second; auto dist = [&](int i, int j) -> ll { return (pos[i].first-pos[j].first)*(pos[i].first-pos[j].first)+(pos[i].second-pos[j].second)*(pos[i].second-pos[j].second); }; vector<int> vs(4); rep(i,4) vs[i] = i; vector<pair<int,int>> vec(3); rep(i,3) vec[i] = make_pair(pos[i+1].first-pos[0].first,pos[i+1].second-pos[0].second); if(vec[1].first*vec[0].second-vec[1].second*vec[0].first==0 && vec[2].first*vec[0].second-vec[2].second*vec[0].first==0){ cout << "NO" << endl; return 0; } do{ ll ab = dist(vs[0],vs[1]); ll ac = dist(vs[0],vs[2]); ll ad = dist(vs[0],vs[3]); ll bc = dist(vs[1],vs[2]); ll bd = dist(vs[1],vs[3]); ll cd = dist(vs[2],vs[3]); ll v1 = ac*bd-ab*cd-ad*bc; ll v2 = 4*ad*bc*ab*cd; dbg(v1*v1,v2); if(v1*v1==v2) { cout << "YES" << endl; return 0; } } while(next_permutation(vs.begin(),vs.end())); cout << "NO" << endl; return 0; }