結果
問題 |
No.3074 Divide Points Fairly
|
ユーザー |
|
提出日時 | 2025-03-29 12:40:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,129 bytes |
コンパイル時間 | 2,177 ms |
コンパイル使用メモリ | 202,928 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-29 12:40:21 |
合計ジャッジ時間 | 6,494 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int D = 100000; struct Point { int x, y; }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int total = 2 * N; vector<Point> pts(total); for (int i = 0; i < total; i++){ cin >> pts[i].x >> pts[i].y; } // 随机生成候选的 a, b 从区间 [0, D) random_device rd; mt19937 gen(rd()); uniform_int_distribution<int> idist(0, D - 1); while (true) { int a = idist(gen); int b = idist(gen); if(a == 0 && b == 0) continue; vector<long long> f(total); for (int i = 0; i < total; i++){ f[i] = (long long)a * pts[i].x + (long long)b * pts[i].y; } sort(f.begin(), f.end()); // 检查中位数附近的差距是否足够大:要求 f[N] - f[N-1] >= 2 if(f[N] - f[N-1] >= 2){ // 与 Python 代码一致,取 c = -f[N] + 1 int c = - (int)f[N] + 1; cout << a << " " << b << " " << c << "\n"; return 0; } } return 0; }