結果
問題 | No.5020 Averaging |
ユーザー | futamegawa |
提出日時 | 2024-02-25 15:18:43 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 5 ms / 1,000 ms |
コード長 | 2,498 bytes |
コンパイル時間 | 2,397 ms |
コンパイル使用メモリ | 212,596 KB |
実行使用メモリ | 6,676 KB |
スコア | 21,778,765 |
最終ジャッジ日時 | 2024-02-25 15:18:48 |
合計ジャッジ時間 | 4,203 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
6,676 KB |
testcase_01 | AC | 5 ms
6,676 KB |
testcase_02 | AC | 4 ms
6,676 KB |
testcase_03 | AC | 5 ms
6,676 KB |
testcase_04 | AC | 5 ms
6,676 KB |
testcase_05 | AC | 5 ms
6,676 KB |
testcase_06 | AC | 5 ms
6,676 KB |
testcase_07 | AC | 4 ms
6,676 KB |
testcase_08 | AC | 5 ms
6,676 KB |
testcase_09 | AC | 5 ms
6,676 KB |
testcase_10 | AC | 5 ms
6,676 KB |
testcase_11 | AC | 4 ms
6,676 KB |
testcase_12 | AC | 5 ms
6,676 KB |
testcase_13 | AC | 5 ms
6,676 KB |
testcase_14 | AC | 4 ms
6,676 KB |
testcase_15 | AC | 5 ms
6,676 KB |
testcase_16 | AC | 5 ms
6,676 KB |
testcase_17 | AC | 5 ms
6,676 KB |
testcase_18 | AC | 5 ms
6,676 KB |
testcase_19 | AC | 4 ms
6,676 KB |
testcase_20 | AC | 5 ms
6,676 KB |
testcase_21 | AC | 5 ms
6,676 KB |
testcase_22 | AC | 4 ms
6,676 KB |
testcase_23 | AC | 5 ms
6,676 KB |
testcase_24 | AC | 4 ms
6,676 KB |
testcase_25 | AC | 5 ms
6,676 KB |
testcase_26 | AC | 4 ms
6,676 KB |
testcase_27 | AC | 4 ms
6,676 KB |
testcase_28 | AC | 5 ms
6,676 KB |
testcase_29 | AC | 5 ms
6,676 KB |
testcase_30 | AC | 5 ms
6,676 KB |
testcase_31 | AC | 5 ms
6,676 KB |
testcase_32 | AC | 4 ms
6,676 KB |
testcase_33 | AC | 5 ms
6,676 KB |
testcase_34 | AC | 5 ms
6,676 KB |
testcase_35 | AC | 4 ms
6,676 KB |
testcase_36 | AC | 5 ms
6,676 KB |
testcase_37 | AC | 5 ms
6,676 KB |
testcase_38 | AC | 5 ms
6,676 KB |
testcase_39 | AC | 4 ms
6,676 KB |
testcase_40 | AC | 5 ms
6,676 KB |
testcase_41 | AC | 5 ms
6,676 KB |
testcase_42 | AC | 5 ms
6,676 KB |
testcase_43 | AC | 5 ms
6,676 KB |
testcase_44 | AC | 4 ms
6,676 KB |
testcase_45 | AC | 5 ms
6,676 KB |
testcase_46 | AC | 4 ms
6,676 KB |
testcase_47 | AC | 5 ms
6,676 KB |
testcase_48 | AC | 4 ms
6,676 KB |
testcase_49 | AC | 5 ms
6,676 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using llu = long long unsigned; vector<ll> dx = { 0, 0, -1, 1}; vector<ll> dy = {-1, 1, 0, 0}; #define TARGET 500000000000000000LL ll scoreCal(ll a0, ll a1, ll b0, ll b1) { ll newA = (a0 + a1) / 2; ll newB = (b0 + b1) / 2; ll score = max( abs(TARGET-newA), abs(TARGET-newB)); return score; } int main() { int N; cin >> N; vector<ll> A(N), B(N); for (int i=0; i<N; ++i) { cin >> A[i] >> B[i]; } vector<ll> Aorg, Borg; Aorg = A; Borg = B; vector<pair<int, int>> ret; for (int i=0; i<50; ++i) { int u = 0; int v = 0; ll minScore = scoreCal(A[0], A[0], B[0], B[0]); //cout << "1 - 1 minScore = " << minScore << endl; for (int j=1; j<N; ++j) { ll score = scoreCal(A[0], A[j], B[0], B[j]); //cout << "1 - " << j+1 << " minScore = " << score << endl; if (score < minScore) { minScore = score; v = j; } } if (v == 0) { break; } ret.push_back(make_pair(u+1, v+1)); //cout << "1 - " << v+1 << " execute" << endl; ll newA = (A[u] + A[v]) / 2; ll newB = (B[u] + B[v]) / 2; A[u] = A[v] = newA; B[u] = B[v] = newB; //for (int i=0; i<N; ++i) { cout << A[i] << " " << B[i] << endl; } } ll minScore = scoreCal(A[0], A[0], B[0], B[0]); //cout << "minScore : " << minScore << endl; //ll minScore = 1e18; srand(static_cast<unsigned>(time(NULL))); for (int count=0; count<1000; ++count) { A.clear(); A = Aorg; B.clear(); B = Borg; vector<pair<int, int>> ret1; for (int i=0; i<50; ++i) { int u = rand()%N; int v = rand()%N; while (u == v) { v = rand()%N; } ret1.push_back(make_pair(u+1, v+1)); ll newA = (A[u] + A[v]) / 2; ll newB = (B[u] + B[v]) / 2; A[u] = A[v] = newA; B[u] = B[v] = newB; } ll tmpScore = scoreCal(A[0], A[0], B[0], B[0]); if (tmpScore < minScore) { minScore = tmpScore; ret.clear(); ret = ret1; } } //cout << "minScore : " << minScore << endl; cout << ret.size() << endl; for (auto x : ret) { cout << x.first << " " << x.second << endl; } return 0; }