結果
問題 | No.5020 Averaging |
ユーザー | 遭難者 |
提出日時 | 2024-02-25 16:25:52 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 954 ms / 1,000 ms |
コード長 | 2,898 bytes |
コンパイル時間 | 7,655 ms |
コンパイル使用メモリ | 345,056 KB |
実行使用メモリ | 6,676 KB |
スコア | 27,441,601 |
最終ジャッジ日時 | 2024-02-25 16:26:50 |
合計ジャッジ時間 | 57,343 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 953 ms
6,676 KB |
testcase_01 | AC | 953 ms
6,676 KB |
testcase_02 | AC | 952 ms
6,676 KB |
testcase_03 | AC | 953 ms
6,676 KB |
testcase_04 | AC | 953 ms
6,676 KB |
testcase_05 | AC | 953 ms
6,676 KB |
testcase_06 | AC | 953 ms
6,676 KB |
testcase_07 | AC | 953 ms
6,676 KB |
testcase_08 | AC | 953 ms
6,676 KB |
testcase_09 | AC | 954 ms
6,676 KB |
testcase_10 | AC | 953 ms
6,676 KB |
testcase_11 | AC | 953 ms
6,676 KB |
testcase_12 | AC | 952 ms
6,676 KB |
testcase_13 | AC | 953 ms
6,676 KB |
testcase_14 | AC | 953 ms
6,676 KB |
testcase_15 | AC | 953 ms
6,676 KB |
testcase_16 | AC | 953 ms
6,676 KB |
testcase_17 | AC | 954 ms
6,676 KB |
testcase_18 | AC | 953 ms
6,676 KB |
testcase_19 | AC | 953 ms
6,676 KB |
testcase_20 | AC | 953 ms
6,676 KB |
testcase_21 | AC | 953 ms
6,676 KB |
testcase_22 | AC | 952 ms
6,676 KB |
testcase_23 | AC | 953 ms
6,676 KB |
testcase_24 | AC | 953 ms
6,676 KB |
testcase_25 | AC | 953 ms
6,676 KB |
testcase_26 | AC | 953 ms
6,676 KB |
testcase_27 | AC | 953 ms
6,676 KB |
testcase_28 | AC | 953 ms
6,676 KB |
testcase_29 | AC | 953 ms
6,676 KB |
testcase_30 | AC | 953 ms
6,676 KB |
testcase_31 | AC | 953 ms
6,676 KB |
testcase_32 | AC | 952 ms
6,676 KB |
testcase_33 | AC | 953 ms
6,676 KB |
testcase_34 | AC | 953 ms
6,676 KB |
testcase_35 | AC | 953 ms
6,676 KB |
testcase_36 | AC | 953 ms
6,676 KB |
testcase_37 | AC | 952 ms
6,676 KB |
testcase_38 | AC | 953 ms
6,676 KB |
testcase_39 | AC | 953 ms
6,676 KB |
testcase_40 | AC | 953 ms
6,676 KB |
testcase_41 | AC | 954 ms
6,676 KB |
testcase_42 | AC | 952 ms
6,676 KB |
testcase_43 | AC | 953 ms
6,676 KB |
testcase_44 | AC | 953 ms
6,676 KB |
testcase_45 | AC | 953 ms
6,676 KB |
testcase_46 | AC | 953 ms
6,676 KB |
testcase_47 | AC | 953 ms
6,676 KB |
testcase_48 | AC | 953 ms
6,676 KB |
testcase_49 | AC | 953 ms
6,676 KB |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> #include <atcoder/all> #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define ALL(a) a.begin(), a.end() typedef long double ldouble; #undef long #define long long long #define vec vector using namespace std; using mint = atcoder::modint; ostream &operator<<(ostream &os, mint a) { return os << a.val(); } template <typename T> ostream &operator<<(ostream &os, vector<T> &a) { const int n = a.size(); rep(i, n) { os << a[i]; if (i + 1 != n) os << " "; } return os; } template <typename T, size_t n> ostream &operator<<(ostream &os, array<T, n> &a) { rep(i, n) os << a[i] << " \n"[i + 1 == n]; return os; } template <typename T> istream &operator>>(istream &is, vector<T> &a) { for (T &i : a) is >> i; return is; } template <typename T> bool chmin(T &x, T y) { if (x > y) { x = y; return true; } return false; } template <typename T> bool chmax(T &x, T y) { if (x < y) { x = y; return true; } return false; } void solve() { const auto start = chrono::system_clock::now(); constexpr int n = 45; int muda; cin >> muda; assert(muda == n); array<long, n> a, b; rep(i, n) cin >> a[i] >> b[i]; array<long, n> aa, bb; constexpr int m = 50; array<int, m> ansu, ansv; constexpr long inf = 5e17; long ans = 7e18; array<int, m> u, v; while (true) { const auto now_time = chrono::system_clock::now(); const auto elapsed_time = chrono::duration_cast<chrono::milliseconds>(now_time - start).count(); if (elapsed_time > 950) break; rep(i, n) { aa[i] = a[i]; bb[i] = b[i]; } if (rand() % 4 == 0) { rep(i, m) u[i] = rand() % n; rep(i, m) v[i] = rand() % n; rep(i, m) { aa[u[i]] = aa[v[i]] = (aa[u[i]] + aa[v[i]]) / 2; bb[u[i]] = bb[v[i]] = (bb[u[i]] + bb[v[i]]) / 2; } } else { rep(i, m) { int idx = 0; long diff = abs(inf - aa[0]); if (rand() % 2 == 0) { for (int j = 1; j < n; j++) { if (chmin(diff, abs(inf - (aa[0] + aa[j]) / 2))) idx = j; } } else { for (int j = 1; j < n; j++) { if (chmin(diff, abs(inf - (bb[0] + bb[j]) / 2))) idx = j; } } u[i] = 0; v[i] = idx; aa[u[i]] = aa[v[i]] = (aa[u[i]] + aa[v[i]]) / 2; bb[u[i]] = bb[v[i]] = (bb[u[i]] + bb[v[i]]) / 2; } } if (chmin(ans, max(abs(aa[0] - inf), abs(bb[0] - inf)))) { rep(i, m) ansu[i] = u[i]; rep(i, m) ansv[i] = v[i]; } } int x = m; rep(i, m) if (ansu[i] == ansv[i]) x--; cout << x << '\n'; rep(i, m) if (ansu[i] != ansv[i]) cout << ansu[i] + 1 << " " << ansv[i] + 1 << '\n'; } int main() { srand((unsigned)time(NULL)); cin.tie(nullptr); ios::sync_with_stdio(false); // cout << fixed << setprecision(400); int t = 1; // cin >> t; while (t--) solve(); return 0; }