結果
| 問題 |
No.3074 Divide Points Fairly
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2025-03-28 23:28:48 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 3,338 bytes |
| コンパイル時間 | 3,798 ms |
| コンパイル使用メモリ | 302,148 KB |
| 実行使用メモリ | 31,200 KB |
| 最終ジャッジ日時 | 2025-03-28 23:29:14 |
| 合計ジャッジ時間 | 25,028 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | WA * 3 RE * 39 |
ソースコード
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define LB(v, x) (int)(lower_bound(ALL(v), x) - (v).begin())
#define UQ(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define IO ios::sync_with_stdio(false), cin.tie(nullptr);
#define chmax(a, b) (a) = (a) < (b) ? (b) : (a)
#define chmin(a, b) (a) = (a) < (b) ? (a) : (b)
using namespace std;
using ll = long long;
const int INF = 1e9 + 10;
const ll INFL = 4e18;
int main() {
auto sign = [&](ll x) {
if (x < 0) return -1;
if (x == 0) return 0;
return 1;
};
auto solve = [&](ll cx, vector<pair<ll, ll>> xy) -> tuple<ll, ll, ll> {
int n = ssize(xy) / 2;
vector<tuple<double, ll, ll>> arg;
for (auto [x, y] : xy) {
arg.emplace_back(atan2(y, x - cx), x, y);
arg.emplace_back(atan2(y, x - cx) + numbers::pi + 2, x, y);
}
sort(ALL(arg));
for (int i = 0; i < 2 * n; i++) {
int j = LB(arg, make_tuple(get<0>(arg[i]) + numbers::pi, -INFL, -INFL));
if (j - i == n) {
auto [t, x, y] = arg[i];
ll bunbo = x - cx, bunsi = -y;
if (abs(bunbo) > abs(bunsi)) {
bunbo = sign(bunbo) * (bunbo + 1);
bunsi = sign(bunsi) * (bunsi + 1);
} else if (abs(bunbo) < abs(bunsi)) {
bunbo = sign(bunbo) * (bunbo - 1);
bunsi = sign(bunsi) * (bunsi - 1);
} else {
bunbo *= 10, bunsi *= 10;
bunbo += 2, bunsi += 1;
}
return make_tuple(bunsi, -bunbo, bunsi * cx);
}
}
return make_tuple(0, 0, 0);
};
int N;
cin >> N;
vector<pair<ll, ll>> XY(2 * N);
for (auto& [x, y] : XY) cin >> x >> y, x *= 2, y *= 2;
auto check = [&](ll a, ll b, ll c) {
int n = 0;
if (b == 0) {
// ax=c
for (auto [x, y] : XY) {
if (a * x == -c) return false;
if (a * x > -c) n++;
}
return n == N / 2;
}
for (auto [x, y] : XY) {
if (a * x + b * y + c == 0) return false;
if (b * y > -a * x - c) n++;
}
return n == N / 2;
};
map<int, int> cnt;
for (auto [x, y] : XY) cnt[x]++;
ll sum = 0;
for (int i = -5e5; i <= 5e5; i += 2) {
sum += cnt[i];
if (sum > N) {
{
auto [a, b, c] = solve(i + 1, XY);
if (a != 0 || b != 0 || c != 0) {
assert(check(a, b, c));
a *= 2, b *= 2;
ll g = gcd(abs(a), gcd(abs(b), abs(c)));
a /= g, b /= g, c /= g;
cout << a << ' ' << b << ' ' << c << endl;
return 0;
}
}
{
auto [a, b, c] = solve(i - 1, XY);
if (a != 0 || b != 0 || c != 0) {
assert(check(a, b, c));
a *= 2, b *= 2;
ll g = gcd(abs(a), gcd(abs(b), abs(c)));
a /= g, b /= g, c /= g;
cout << a << ' ' << b << ' ' << c << endl;
return 0;
}
}
}
}
}
Today03