結果
問題 | No.5020 Averaging |
ユーザー | てんぷら |
提出日時 | 2024-02-25 14:24:40 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 953 ms / 1,000 ms |
コード長 | 3,959 bytes |
コンパイル時間 | 5,717 ms |
コンパイル使用メモリ | 313,704 KB |
実行使用メモリ | 6,548 KB |
スコア | 33,018,372 |
最終ジャッジ日時 | 2024-02-25 14:25:36 |
合計ジャッジ時間 | 55,644 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 952 ms
6,548 KB |
testcase_01 | AC | 952 ms
6,548 KB |
testcase_02 | AC | 952 ms
6,548 KB |
testcase_03 | AC | 952 ms
6,548 KB |
testcase_04 | AC | 951 ms
6,548 KB |
testcase_05 | AC | 952 ms
6,548 KB |
testcase_06 | AC | 952 ms
6,548 KB |
testcase_07 | AC | 952 ms
6,548 KB |
testcase_08 | AC | 952 ms
6,548 KB |
testcase_09 | AC | 952 ms
6,548 KB |
testcase_10 | AC | 952 ms
6,548 KB |
testcase_11 | AC | 952 ms
6,548 KB |
testcase_12 | AC | 952 ms
6,548 KB |
testcase_13 | AC | 952 ms
6,548 KB |
testcase_14 | AC | 952 ms
6,548 KB |
testcase_15 | AC | 952 ms
6,548 KB |
testcase_16 | AC | 952 ms
6,548 KB |
testcase_17 | AC | 952 ms
6,548 KB |
testcase_18 | AC | 952 ms
6,548 KB |
testcase_19 | AC | 952 ms
6,548 KB |
testcase_20 | AC | 952 ms
6,548 KB |
testcase_21 | AC | 952 ms
6,548 KB |
testcase_22 | AC | 952 ms
6,548 KB |
testcase_23 | AC | 952 ms
6,548 KB |
testcase_24 | AC | 951 ms
6,548 KB |
testcase_25 | AC | 952 ms
6,548 KB |
testcase_26 | AC | 952 ms
6,548 KB |
testcase_27 | AC | 953 ms
6,548 KB |
testcase_28 | AC | 952 ms
6,548 KB |
testcase_29 | AC | 952 ms
6,548 KB |
testcase_30 | AC | 952 ms
6,548 KB |
testcase_31 | AC | 952 ms
6,548 KB |
testcase_32 | AC | 952 ms
6,548 KB |
testcase_33 | AC | 952 ms
6,548 KB |
testcase_34 | AC | 952 ms
6,548 KB |
testcase_35 | AC | 952 ms
6,548 KB |
testcase_36 | AC | 952 ms
6,548 KB |
testcase_37 | AC | 952 ms
6,548 KB |
testcase_38 | AC | 952 ms
6,548 KB |
testcase_39 | AC | 952 ms
6,548 KB |
testcase_40 | AC | 953 ms
6,548 KB |
testcase_41 | AC | 952 ms
6,548 KB |
testcase_42 | AC | 952 ms
6,548 KB |
testcase_43 | AC | 952 ms
6,548 KB |
testcase_44 | AC | 951 ms
6,548 KB |
testcase_45 | AC | 952 ms
6,548 KB |
testcase_46 | AC | 952 ms
6,548 KB |
testcase_47 | AC | 953 ms
6,548 KB |
testcase_48 | AC | 952 ms
6,548 KB |
testcase_49 | AC | 952 ms
6,548 KB |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using ll = long long; using ull = unsigned long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++) using namespace std; using namespace atcoder; using mint = modint998244353; const int inf = 1000000007; const ll longinf = 1ll << 60; struct Timer { chrono::system_clock::time_point start, last_updated; Timer() { start = chrono::system_clock::now(); last_updated = chrono::system_clock::now(); } void reset() { start = chrono::system_clock::now(); } void update() { last_updated = chrono::system_clock::now(); } double getTime() { auto now = chrono::system_clock::now(); return chrono::duration<double>(now - start).count(); } double should_finish_search1() { return getTime() > 5.8; } bool should_reset() { auto now = chrono::system_clock::now(); return chrono::duration<double>(now - last_updated).count() > 1.0 || chrono::duration<double>(now - start).count() > 5.8; } }; Timer timer; struct Xor128 { unsigned x, y, z, w; Xor128() : x(123456789), y(362436069), z(521288629), w(88675123){}; inline unsigned xor128() { unsigned t; t = x ^ (x << 11); x = y; y = z; z = w; return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); } int nextInt(int x, int y) { return xor128() % (y - x) + x; } double nextDouble(double a, double b) { return (double)(xor128() & 0xffff) / 0xffff * (b - a) + a; } }; auto rnd = Xor128(); double calculate_score(ll x) { return 2000000 - 100000 * log10(abs(x - (ll)5e17) + 1); } double calculate_current_score(vector<ll> &a, vector<ll> &b, double t) { double ret = 0; rep(i, a.size()) { double res = min(calculate_score(a[i]), calculate_score(b[i])); if(i > 0) res *= 0; ret += res; } return ret; } void output(vector<pair<int, int>> &query) { cout << query.size() << endl; for(auto [l, r] : query) { cout << l + 1 << " " << r + 1 << endl; } } void do_query(vector<ll> &a, vector<ll> &b, int i, int j) { ll x = (a[i] + a[j]) / 2; ll y = (b[i] + b[j]) / 2; a[i] = a[j] = x; b[i] = b[j] = y; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<ll> a(n), b(n); rep(i, n) cin >> a[i] >> b[i]; vector<pair<int, int>> query; vector<ll> a_state = a, b_state = b; rep(_, 50) { int x = rnd.nextInt(0, n); int y = rnd.nextInt(0, n - 1); if(y >= x) ++y; query.emplace_back(x, y); do_query(a_state, b_state, x, y); } double score = 0; double t0 = 1e6; double t1 = 1; double tl = 0.95; double t = 0; int itr = 0; double time = 0; while(1) { if(!(itr & 31)) { time = timer.getTime() / tl; if(time > 1.0) break; t = pow(t0, 1 - time) * pow(t1, time); } double cur = calculate_current_score(a_state, b_state, time); vector<ll> na = a, nb = b; int idx = rnd.nextInt(0, 50); int x = rnd.nextInt(0, n), y = rnd.nextInt(0, n - 1); if(y >= x) ++y; rep(j, 50) { if(j == idx) { do_query(na, nb, x, y); } else { do_query(na, nb, query[j].first, query[j].second); } } double nxt = calculate_current_score(na, nb, time); double prob = exp((nxt - cur) / t); if(rnd.nextDouble(0, 1) < prob) { query[idx] = {x, y}; a_state = na; b_state = nb; } } output(query); cerr << 50 * min(calculate_score(a_state[0]), calculate_score(b_state[0])) << endl; return 0; }