結果
問題 |
No.3074 Divide Points Fairly
|
ユーザー |
|
提出日時 | 2025-03-28 22:28:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,879 bytes |
コンパイル時間 | 2,053 ms |
コンパイル使用メモリ | 203,108 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-28 22:28:29 |
合計ジャッジ時間 | 6,154 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; 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; } // ① 先尝试竖直直线方案:按 x 坐标排序(当 x 相同时按 y 排序) { vector<Point> temp = pts; sort(temp.begin(), temp.end(), [](const Point &a, const Point &b){ return a.x == b.x ? a.y < b.y : a.x < b.x; }); int x_low = temp[N-1].x, x_high = temp[N].x; if(x_low < x_high){ if(x_low + 1 < x_high){ int t = x_low + 1; cout << 1 << " " << 0 << " " << -t << "\n"; return 0; } else { int t = 2 * x_low + 1; cout << 2 << " " << 0 << " " << -t << "\n"; return 0; } } } // ② 当竖直方案不可行,则必有部分点共享相同 x 值,此时尝试水平直线方案:按 y 坐标排序(当 y 相同时按 x 排序) { vector<Point> temp = pts; sort(temp.begin(), temp.end(), [](const Point &a, const Point &b){ return a.y == b.y ? a.x < b.x : a.y < b.y; }); int y_low = temp[N-1].y, y_high = temp[N].y; if(y_low < y_high){ if(y_low + 1 < y_high){ int t = y_low + 1; cout << 0 << " " << 1 << " " << -t << "\n"; return 0; } else { int t = 2 * y_low + 1; cout << 0 << " " << 2 << " " << -t << "\n"; return 0; } } } // ③ 按理来说至少有一种方案必定可行,故此处理论上不会到达 cout << "1 0 0\n"; return 0; }