結果
問題 | No.5020 Averaging |
ユーザー | ldsyb |
提出日時 | 2024-02-25 15:52:30 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 903 ms / 1,000 ms |
コード長 | 3,125 bytes |
コンパイル時間 | 6,307 ms |
コンパイル使用メモリ | 337,548 KB |
実行使用メモリ | 6,676 KB |
スコア | 17,305,646 |
最終ジャッジ日時 | 2024-02-25 15:53:54 |
合計ジャッジ時間 | 54,063 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 903 ms
6,676 KB |
testcase_01 | AC | 902 ms
6,676 KB |
testcase_02 | AC | 901 ms
6,676 KB |
testcase_03 | AC | 902 ms
6,676 KB |
testcase_04 | AC | 902 ms
6,676 KB |
testcase_05 | AC | 902 ms
6,676 KB |
testcase_06 | AC | 902 ms
6,676 KB |
testcase_07 | AC | 902 ms
6,676 KB |
testcase_08 | AC | 902 ms
6,676 KB |
testcase_09 | AC | 903 ms
6,676 KB |
testcase_10 | AC | 902 ms
6,676 KB |
testcase_11 | AC | 902 ms
6,676 KB |
testcase_12 | AC | 901 ms
6,676 KB |
testcase_13 | AC | 902 ms
6,676 KB |
testcase_14 | AC | 902 ms
6,676 KB |
testcase_15 | AC | 902 ms
6,676 KB |
testcase_16 | AC | 902 ms
6,676 KB |
testcase_17 | AC | 902 ms
6,676 KB |
testcase_18 | AC | 902 ms
6,676 KB |
testcase_19 | AC | 902 ms
6,676 KB |
testcase_20 | AC | 902 ms
6,676 KB |
testcase_21 | AC | 901 ms
6,676 KB |
testcase_22 | AC | 902 ms
6,676 KB |
testcase_23 | AC | 902 ms
6,676 KB |
testcase_24 | AC | 902 ms
6,676 KB |
testcase_25 | AC | 902 ms
6,676 KB |
testcase_26 | AC | 902 ms
6,676 KB |
testcase_27 | AC | 902 ms
6,676 KB |
testcase_28 | AC | 903 ms
6,676 KB |
testcase_29 | AC | 902 ms
6,676 KB |
testcase_30 | AC | 902 ms
6,676 KB |
testcase_31 | AC | 902 ms
6,676 KB |
testcase_32 | AC | 902 ms
6,676 KB |
testcase_33 | AC | 902 ms
6,676 KB |
testcase_34 | AC | 901 ms
6,676 KB |
testcase_35 | AC | 902 ms
6,676 KB |
testcase_36 | AC | 902 ms
6,676 KB |
testcase_37 | AC | 902 ms
6,676 KB |
testcase_38 | AC | 902 ms
6,676 KB |
testcase_39 | AC | 902 ms
6,676 KB |
testcase_40 | AC | 902 ms
6,676 KB |
testcase_41 | AC | 902 ms
6,676 KB |
testcase_42 | AC | 902 ms
6,676 KB |
testcase_43 | AC | 902 ms
6,676 KB |
testcase_44 | AC | 901 ms
6,676 KB |
testcase_45 | AC | 902 ms
6,676 KB |
testcase_46 | AC | 902 ms
6,676 KB |
testcase_47 | AC | 902 ms
6,676 KB |
testcase_48 | AC | 902 ms
6,676 KB |
testcase_49 | AC | 902 ms
6,676 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using namespace chrono; #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif int main() { const auto start = steady_clock::now(); std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int64_t n; cin >> n; vector<int64_t> as(n), bs(n); for (int64_t i = 0; i < n; i++) { cin >> as[i] >> bs[i]; } random_device rnd; mt19937 engine(rnd()); uniform_int_distribution<> randn(0, n - 1); int64_t c = 500000000000000000LL; auto calc_score = [&] { return int64_t(2000000 - 100000 * log10(max(abs(as[0] - c), abs(bs[0] - c)) + 1)); }; auto f = [&](int64_t a, int64_t b) { return max(abs(a - c), abs(b - c)); }; pair<int64_t, int64_t> p = {2 * c - as[0], 2 * c - bs[0]}; auto g = [&](int64_t a, int64_t b) { return 2 * logl(abs(a - p.first) + abs(b - p.second)) / (logl(2 * abs(a - p.first)) + logl(abs(b - p.second))); }; using T = pair<pair<long double, vector<int64_t>>, pair<vector<int64_t>, vector<int64_t>>>; vector<priority_queue<T, vector<T>, greater<>>> pqs(50); for (int64_t i = 1; i < n; i++) { vector<int64_t> v; v.push_back(i); pqs[0].push({{g(as[i], bs[i]), v}, {as, bs}}); } long double s = (1LL << 60); vector<int64_t> xs; while (duration_cast<milliseconds>(steady_clock::now() - start).count() < 900) { for (int64_t i = 0; i < 50; i++) { if (pqs[i].empty()) { continue; } auto [pp, qq] = pqs[i].top(); pqs[i].pop(); auto [d, v] = pp; auto [cs, ds] = qq; if (d < s) { s = d; xs = v; } if (i + 1 < 50) { for (int64_t k = 1; k < n; k++) { if (v.back() == k) { continue; } int64_t j = v.back(); v.push_back(k); int64_t w = cs[j], x = ds[j]; int64_t y = cs[k], z = ds[k]; cs[j] = cs[k] = (w + x) / 2; ds[j] = ds[k] = (y + z) / 2; if (pqs[i + 1].empty() || g(cs[k], ds[k]) < pqs[i + 1].top().first.first) { pqs[i + 1].push({{g(cs[k], ds[k]), v}, {cs, ds}}); } cs[j] = w; ds[j] = x; cs[k] = y; ds[k] = z; v.pop_back(); } } } } vector<int64_t> us, vs; for (int64_t i = 1; i < xs.size(); i++) { us.push_back(xs[i - 1] + 1); vs.push_back(xs[i] + 1); } us.push_back(1); vs.push_back([&] { int64_t ret = 1; for (int64_t i = 2; i < n; i++) { int64_t x = (as[0] + as[i]) / 2; int64_t y = (bs[0] + bs[i]) / 2; int64_t a = (as[0] + as[ret]) / 2; int64_t b = (bs[0] + bs[ret]) / 2; if (f(x, y) < f(a, b)) { ret = i; } } ret++; return ret; }()); cout << us.size() << '\n'; for (int64_t i = 0; i < us.size(); i++) { cout << us[i] << ' ' << vs[i] << '\n'; } // cerr << calc_score() << endl; // for (int64_t i = 0; i < n; i++) { // cerr << as[i] << ' ' << bs[i] << endl; // } return 0; }