結果

問題 No.3057 Tree Distance Set
ユーザー pockyny
提出日時 2025-07-12 04:31:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 86,044 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-07-12 04:31:48
合計ジャッジ時間 4,685 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 3 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
    int i,k; cin >> k;
    vector<int> d(k);
    for(i=0;i<k;i++) cin >> d[i];
    sort(d.rbegin(),d.rend());
    vector<pair<pair<int,int>,int>> ans;
    vector<int> s;
    int l = d[0]/2,idx = 4,c = 1;
    ans.push_back({{c,2},l});
    ans.push_back({{c,3},l});
    s.push_back(2); s.push_back(3);
    for(i=1;i<k;i++){
        ans.push_back({{c,idx},l - d[i]/2});
        ans.push_back({{idx,idx + 1},d[i]/2});
        ans.push_back({{idx,idx + 2},d[i]/2});
        s.push_back(idx + 1); s.push_back(idx + 2);
        idx += 3;
    }
    cout << idx - 1 << "\n";
    for(auto [uv,w]:ans){
        auto [u,v] = uv;
        cout << u << " " << v << " " << w << "\n";
    }
    for(int x:s) cout << x << " ";
    cout << "\n";
}
0