結果

問題 No.5020 Averaging
ユーザー nimanima
提出日時 2024-02-25 14:47:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,181 bytes
コンパイル時間 1,767 ms
コンパイル使用メモリ 173,924 KB
実行使用メモリ 6,676 KB
スコア 12,110,557
最終ジャッジ日時 2024-02-25 14:47:50
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 AC 1 ms
6,676 KB
testcase_38 AC 2 ms
6,676 KB
testcase_39 AC 2 ms
6,676 KB
testcase_40 AC 2 ms
6,676 KB
testcase_41 AC 2 ms
6,676 KB
testcase_42 AC 2 ms
6,676 KB
testcase_43 AC 2 ms
6,676 KB
testcase_44 AC 2 ms
6,676 KB
testcase_45 AC 2 ms
6,676 KB
testcase_46 WA -
testcase_47 AC 1 ms
6,676 KB
testcase_48 AC 2 ms
6,676 KB
testcase_49 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;

// グローバル変数
ll n;
vector<ll> a, b;
vector<pair<ll, ll>> ans;
ll st = 500000000000000000;

void input(){
    cin >> n;

    rep(i, n){
        ll u, v; cin >> u >> v;
        a.push_back(u);
        b.push_back(v);
    }
}

pair<ll, ll> average(int idx1, int idx2){
    return {(a[idx1]+a[idx2])/2, (b[idx1]+b[idx2])/2};
}

ll score(ll num1, ll num2){
    return max(st-num1, st-num2);
}

ll use(){
    pair<ll, ll> ret;  // s{score, idx}
    rep(i, n-1){
        pair<ll, ll> tmp = average(0, i+1);
        ll tmps = score(tmp.first, tmp.second);
        if(tmps < ret.first) ret = {tmps, i+1};
    }

    ans.push_back({1, ret.second+1});
    pair<ll, ll> c = average(0, ret.second);
    a[0] = c.first;
    a[ret.second] = c.first;
    b[0] = c.second;
    b[ret.second] = c.second;

    return ret.second;
}

void calc(){
    rep(i, 50){
        use();
    }
}

void output(){
    cout << ans.size() << endl;
    for(auto i : ans){
        cout << i.first << " " << i.second << endl;
    }
}

int main(){
    input();
    calc();
    output();
}
0