結果

問題 No.1523 +/- Tree
ユーザー vkgainz
提出日時 2021-06-05 09:53:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 943 bytes
コンパイル時間 1,670 ms
コンパイル使用メモリ 168,212 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 05:55:42
合計ジャッジ時間 5,459 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N, K; cin >> N >> K;
    if(N - 1 == K) {
        cout << "No";
        return 0;
    }
    if((N - 1) % K == 0) {
        cout << "Yes" << "\n";
        for(int i = 0; i < K - 1; i++) {
            cout << i + 1 << " " << i + 2 << " ";
            if(i == K - 2) {
                cout << -5001*(K - 1) - 1 << "\n";
            }
            else {
                cout << 5001 << "\n";
            }
        }
        for(int i = K - 1; i < N - 1; i++) {
            cout << i + 1 << " " << i + 2 << " ";
            cout << 5001 << "\n";
        }
    }
    else {
        cout << "Yes" << "\n";
        for(int i = 0; i < N - 1; i++) {
            cout << i + 1 << " " << i + 2 << " ";
            if(i%K == K - 1) {
                cout << -5001*(K - 1) - 1 << "\n";
            }
            else {
                cout << 5001 << "\n";
            }
        }
    }
}
0