結果
問題 | No.1523 +/- Tree |
ユーザー |
![]() |
提出日時 | 2021-05-28 21:19:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 1,172 bytes |
コンパイル時間 | 3,197 ms |
コンパイル使用メモリ | 193,068 KB |
最終ジャッジ日時 | 2025-01-21 19:37:12 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 44 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int N,K;cin >> N >> K;if(K == 1) {cout << "No" << endl;}else if(K == 2) {if(N%2 == 1) {cout << "No" << endl;}else {cout << "Yes" << endl;for(int i = 0; i < N-1; i++) {cout << i+1 << " " << i+2 << " " << ((i%2 == 0)?2000:-2001) << endl;}}}else {if(K == N-1) {cout << "No" << endl;}else if(K == 3 && N == 5) {cout << "Yes" << endl;cout << 1 << " " << 2 << " " << -2 << endl;cout << 2 << " " << 3 << " " << -2 << endl;cout << 3 << " " << 4 << " " << 3 << endl;cout << 3 << " " << 5 << " " << 3 << endl;}else {cout << "Yes" << endl;for(int i = 0; i < N-1; i++) {if(i < K-1) {cout << i+1 << " " << i+2 << " " << -1 << endl;}else {cout << K << " " << i+2 << " " << K-2 << endl;}}}}}