結果

問題 No.5020 Averaging
ユーザー ldsyb
提出日時 2024-02-25 14:20:12
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 2,382 bytes
コンパイル時間 5,208 ms
コンパイル使用メモリ 314,100 KB
実行使用メモリ 6,676 KB
スコア 19,641,768
最終ジャッジ日時 2024-02-25 14:20:20
合計ジャッジ時間 7,073 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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<> randt(0, 45);
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));
};
vector<int64_t> us, vs;
for (int64_t t = 0; t < 50; t++) {
if (t % 2 == 0) {
int64_t p = 1, q = 2;
if (t != 49 && t < 2 * randt(engine)) {
p = randn(engine);
do {
q = randn(engine);
} while (p == q);
} else {
for (int64_t i = 1; i < n; i++) {
for (int64_t j = i + 1; j < n; j++) {
int64_t x = (as[i] + as[j]) / 2;
int64_t y = (bs[i] + bs[j]) / 2;
int64_t a = (as[p] + as[q]) / 2;
int64_t b = (bs[p] + bs[q]) / 2;
if (max(abs(as[0] + x) / 2 - c, abs(bs[0] + y) / 2 - c) <
max(abs(as[0] + a) / 2 - c, abs(bs[0] + b) / 2 - c)) {
p = i;
q = j;
}
}
}
}
int64_t x = (as[p] + as[q]) / 2;
int64_t y = (bs[p] + bs[q]) / 2;
as[p] = as[q] = x;
bs[p] = bs[q] = y;
us.push_back(p + 1);
vs.push_back(q + 1);
} else {
int64_t i = 1;
for (int64_t j = 2; j < n; j++) {
if (max(abs((as[0] + as[j]) / 2 - c), abs((bs[0] + bs[j]) / 2 - c)) <
max(abs((as[0] + as[i]) / 2 - c), abs((bs[0] + bs[i]) / 2 - c))) {
i = j;
}
}
int64_t x = (as[0] + as[i]) / 2;
int64_t y = (bs[0] + bs[i]) / 2;
as[0] = as[i] = x;
bs[0] = bs[i] = y;
us.push_back(1);
vs.push_back(i + 1);
}
}
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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0