結果
問題 |
No.3074 Divide Points Fairly
|
ユーザー |
|
提出日時 | 2025-03-28 22:26:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 1,180 bytes |
コンパイル時間 | 2,212 ms |
コンパイル使用メモリ | 198,612 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-28 22:26:15 |
合計ジャッジ時間 | 5,250 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) random_device seed_gen; mt19937 engine(seed_gen()); void solve() { ll n; cin >> n; vector<ll> x(n * 2), y(n * 2); rep(i, n * 2) cin >> x[i] >> y[i]; for (;;) { const ll a = engine() % 200'001 - 100'000; const ll b = engine() % 200'001 - 100'000; if (a == 0 && b == 0) continue; auto calc = [&](const ll c) -> pair<ll, bool> { ll res = 0, found = false; rep(i, n * 2) { if (b * y[i] > -a * x[i] - c) res++; if (b * y[i] == -a * x[i] - c) found = true; } return {res, found}; }; ll ng = -ll(2e10) - 1, ok = ll(2e10); while (ng + 1 < ok) { ll c = (ng + ok) / 2; if (calc(c).first >= n) { ok = c; } else { ng = c; } } auto [res, found] = calc(ok); if (!found && res == n) { cout << a << ' ' << b << ' ' << ok << '\n'; return; } } } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }