結果

問題 No.3057 Tree Distance Set
ユーザー Iroha_3856
提出日時 2025-03-14 22:22:48
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 3,922 ms
コンパイル使用メモリ 279,700 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-14 22:22:57
合計ジャッジ時間 4,734 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, l, r) for (int i = (int)(l); i<(int)(r); i++)
#define ll long long

int main() {
    int K; cin >> K;
    vector<int> D(K);
    rep(i, 0, K) cin >> D[i];
    sort(D.begin(), D.end());
    int N = 2 * K + 1;
    cout << N << endl;
    int now = K+2;
    cout << 1 << " " << now << " " << D[0]/2 << endl;
    cout << 2 << " " << now << " " << D[0]/2 << endl;
    for (int i = 3; i <= K+1; i++) {
        cout << now << " " << (++now) << " " << (D[i-2]-D[i-3])/2 << endl;
        cout << now << " " << i << " " << D[i-2]/2 << endl;
    }
    cout << K+1 << endl;
    rep(i, 1, K+2) cout << i << " ";
    cout << endl;
}
0