結果
問題 |
No.3074 Divide Points Fairly
|
ユーザー |
|
提出日時 | 2025-03-28 22:25:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,362 bytes |
コンパイル時間 | 2,295 ms |
コンパイル使用メモリ | 209,788 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-28 22:26:04 |
合計ジャッジ時間 | 8,082 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int total = 2 * N; vector<pair<int,int>> pts(total); for (int i = 0; i < total; i++){ int x, y; cin >> x >> y; pts[i] = {x, y}; } { vector<pair<int,int>> pts_x = pts; sort(pts_x.begin(), pts_x.end(), [](const pair<int,int> &a, const pair<int,int> &b){ if(a.first != b.first) return a.first < b.first; return a.second < b.second; }); int X1 = pts_x[N-1].first, X2 = pts_x[N].first; if(X1 != X2){ int A = 2, B = 0; long long C = - ( (long long)X1 + X2 ); cout << A << " " << B << " " << C; return 0; } } { vector<pair<int,int>> pts_y = pts; sort(pts_y.begin(), pts_y.end(), [](const pair<int,int> &a, const pair<int,int> &b){ if(a.second != b.second) return a.second < b.second; return a.first < b.first; }); int Y1 = pts_y[N-1].second, Y2 = pts_y[N].second; if(Y1 != Y2){ int A = 0, B = 2; long long C = - ( (long long)Y1 + Y2 ); cout << A << " " << B << " " << C; return 0; } } vector<pair<int,int>> cand; for (int a = -8; a <= 8; a++){ for (int b = -8; b <= 8; b++){ if(a == 0 && b == 0) continue; cand.push_back({a, b}); } } for(auto &cb : cand){ int a = cb.first, b = cb.second; int maxScale = 100000; if(a != 0) maxScale = min(maxScale, 100000 / abs(a)); if(b != 0) maxScale = min(maxScale, 100000 / abs(b)); vector<long long> base(total); for (int i = 0; i < total; i++){ base[i] = (long long)a * pts[i].first + (long long)b * pts[i].second; } sort(base.begin(), base.end()); long long gap = base[N] - base[N - 1]; if(gap <= 0) continue; int k_min = (2 + gap - 1) / gap; // 相当于 ceil(2.0/gap) if(k_min < 1) k_min = 1; if(k_min <= maxScale){ int A = a * k_min, B = b * k_min; long long C = -( (long long) k_min * base[N - 1] + 1 ); cout << A << " " << B << " " << C; return 0; } } return 0; }