結果
問題 | No.1571 All Your Cycles Are Same Lengths |
ユーザー |
|
提出日時 | 2021-06-27 15:18:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 532 ms |
コンパイル使用メモリ | 68,340 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 11:14:01 |
合計ジャッジ時間 | 1,211 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long LL; const int N = 300; int g[N][N]; int main(){ int T; cin>>T; while(T--){ int n,t; cin>>n>>t; if(((n-2)%2==0)&&(t%2)||(t%2&&(n-2%2)&&t<n-2)){ puts("No"); continue; }else{ puts("Yes"); int w=0; if(n-2!=0&&t%2) { w=1; } for(int i=2;i<=n;i++){ for(int j=i;j<=n;j++) g[i][j]=w; } w=t-w*(n-2); w/=2; for(int i=1;i<=n;i++) g[1][i]=w; for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ printf("%d %d %d\n",i,j,g[i][j]); } } } } return 0; }