結果

問題 No.1523 +/- Tree
ユーザー SSRS
提出日時 2021-05-28 20:44:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 1,604 ms
コンパイル使用メモリ 166,864 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 08:18:56
合計ジャッジ時間 4,721 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 37 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
int main(){
  int N, K;
  cin >> N >> K;
  if (K == 1){
    cout << "No" << endl;
  } else if (K == 2){
    if (N % 2 == 0){
      cout << "Yes" << endl;
      for (int i = 0; i < N - 1; i++){
        int w;
        if (i % 2 == 0){
          w = INF;
        } else {
          w = -(INF + 1);
        }
        cout << i + 1 << ' ' << i + 2 << ' ' << w << endl;
      }
    } else {
      cout << "No" << endl;
    }
  } else if (K == N - 1){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (int i = 0; i < N - 3; i++){
      cout << i + 1 << ' ' << i + 2 << ' ' << -2 << endl;
    }
    cout << N - 2 << ' ' << N - 1 << ' ' << K * 2 - 3 << endl;
    cout << N - 2 << ' ' << N << ' ' << K * 2 - 3 << endl;
  }
}
0