結果
問題 | No.1571 All Your Cycles Are Same Lengths |
ユーザー |
![]() |
提出日時 | 2021-06-27 14:52:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,353 bytes |
コンパイル時間 | 2,203 ms |
コンパイル使用メモリ | 194,300 KB |
最終ジャッジ日時 | 2025-01-22 14:25:27 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int Q; cin >> Q; while (Q--) { int N,T; cin >> N >> T; if(N <= 3) { cout << "Yes" << endl; for(int i = 1; i <= N; i++) { for(int j = i+1; j <= N; j++) { if(i == 1 && j == 2) { cout << i << " " << j << " " << T << endl; } else { cout << i << " " << j << " " << 0 << endl; } } } } else if(T%2 != 0 && T%N != 0) { cout << "No" << endl; } else if(T%N == 0) { cout << "Yes" << endl; for(int i = 1; i <= N; i++) { for(int j = i+1; j <= N; j++) { cout << i << " " << j << " " << T/N << endl; } } } else { cout << "Yes" << endl; for(int i = 1; i <= N; i++) { for(int j = i+1; j <= N; j++) { if(i == 1) { cout << i << " " << j << " " << T/2 << endl; } else { cout << i << " " << j << " " << 0 << endl; } } } } } }