結果
問題 | No.3074 Divide Points Fairly |
ユーザー |
👑 |
提出日時 | 2025-03-25 07:34:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 2,155 ms |
コンパイル使用メモリ | 201,364 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-27 12:54:18 |
合計ジャッジ時間 | 6,723 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include<bits/stdc++.h>using namespace std;const int D = 10000;random_device seed;mt19937 mt(seed());uniform_int_distribution dist(-D, D);int main(){int n;cin >> n;vector<long long> x(2 * n), y(2 * n);for(int i = 0; i < 2 * n; i++) cin >> x[i] >> y[i];auto solve = [&](long long a, long long b) -> pair<bool, long long>{if(a == 0 and b == 0) return make_pair(false, 0LL);vector<long long> g(2 * n);for(int i = 0; i < 2 * n; i++) g[i] = a * x[i] + b * y[i];sort(g.begin(), g.end());if(g[n] - g[n - 1] <= 1) return make_pair(false, 0LL);else return make_pair(true, -g[n] + 1);};{long long a = dist(mt), b = dist(mt);auto [success, c] = solve(a, b);if(success){cout << a << ' ' << b << ' ' << c << "\n";return 0;}}return 0;}