結果
問題 |
No.3005 トレミーの問題
|
ユーザー |
![]() |
提出日時 | 2025-01-23 14:53:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,552 bytes |
コンパイル時間 | 2,109 ms |
コンパイル使用メモリ | 200,644 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-23 14:53:19 |
合計ジャッジ時間 | 3,415 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } // sign of permutation int sgn(vector<int> &p) { int n = p.size(); int res = 1; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (p[i] > p[j]) { res *= -1; } } } return res; } // det long long det(vector<vector<long long>> &a) { int n = a.size(); long long res = 0; vector<int> p(n); iota(p.begin(), p.end(), 0); do { long long cur = 1; for (int i = 0; i < n; i++) { cur *= a[i][p[i]]; } res += cur * sgn(p); } while (next_permutation(p.begin(), p.end())); return res; } bool is_collinear(long long ax, long long ay, long long bx, long long by, long long cx, long long cy) { return (bx - ax) * (cy - ay) == (by - ay) * (cx - ax); } int main() { fast_io(); long long ax, ay, bx, by, cx, cy, dx, dy; cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy; if (is_collinear(ax, ay, bx, by, cx, cy) && is_collinear(ax, ay, bx, by, dx, dy)) { cout << "NO" << endl; return 0; } vector<vector<long long>> a = {{ax, ay, ax * ax + ay * ay, 1}, {bx, by, bx * bx + by * by, 1}, {cx, cy, cx * cx + cy * cy, 1}, {dx, dy, dx * dx + dy * dy, 1}}; cout << (det(a) == 0 ? "YES" : "NO") << endl; }