結果
問題 |
No.3074 Divide Points Fairly
|
ユーザー |
![]() |
提出日時 | 2025-03-28 22:57:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,107 bytes |
コンパイル時間 | 4,004 ms |
コンパイル使用メモリ | 302,636 KB |
実行使用メモリ | 29,944 KB |
最終ジャッジ日時 | 2025-03-28 22:58:14 |
合計ジャッジ時間 | 15,788 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 2 WA * 17 TLE * 1 -- * 22 |
ソースコード
#include <bits/stdc++.h> #define ALL(x) (x).begin(), (x).end() #define LB(v, x) (int)(lower_bound(ALL(v), x) - (v).begin()) #define UQ(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end()) #define IO ios::sync_with_stdio(false), cin.tie(nullptr); #define chmax(a, b) (a) = (a) < (b) ? (b) : (a) #define chmin(a, b) (a) = (a) < (b) ? (a) : (b) using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; int main() { auto solve = [&](ll cx, vector<pair<ll, ll>> xy) -> tuple<ll, ll, ll> { int n = ssize(xy) / 2; vector<tuple<double, ll, ll>> arg; for (auto [x, y] : xy) { arg.emplace_back(atan2(y, x - cx), x, y); arg.emplace_back(atan2(y, x - cx) + numbers::pi + 2, x, y); } sort(ALL(arg)); for (int i = 0; i < 2 * n; i++) { int j = LB(arg, make_tuple(get<0>(arg[i]) + numbers::pi, -INFL, -INFL)); if (j - i == n) { auto [t, x, y] = arg[i]; return make_tuple(y, x - cx, -y * cx); } } return make_tuple(0, 0, 0); }; int N; cin >> N; vector<pair<ll, ll>> XY(2 * N); for (auto& [x, y] : XY) cin >> x >> y, x *= 2, y *= 2; map<int, int> cnt; for (auto [x, y] : XY) cnt[x]++; ll sum = 0; for (int i = -5e5; i <= 5e5; i += 2) { sum += cnt[i]; if (sum >= N) { { auto [a, b, c] = solve(i + 1, XY); if (a != 0 || b != 0 || c != 0) { ll g = gcd(abs(a), gcd(abs(b), abs(c))); a /= g, b /= g, c /= g; cout << a << ' ' << b << ' ' << c << endl; return 0; } } { auto [a, b, c] = solve(i - 1, XY); if (a != 0 || b != 0 || c != 0) { ll g = gcd(abs(a), gcd(abs(b), abs(c))); a /= g, b /= g, c /= g; cout << a << ' ' << b << ' ' << c << endl; return 0; } } } } }