結果
問題 | No.1571 All Your Cycles Are Same Lengths |
ユーザー |
|
提出日時 | 2021-06-30 07:01:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 761 bytes |
コンパイル時間 | 571 ms |
コンパイル使用メモリ | 65,840 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 08:59:39 |
合計ジャッジ時間 | 1,472 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; int Q,N,T; int A[8][8]; main() { cin>>Q; for(;Q--;) { cin>>N>>T; if(N==2) { if(T%2==0) { cout<<"Yes"<<endl; cout<<"1 2 "<<T/2<<endl; } else cout<<"No"<<endl; continue; } int a=2,b=N,c=N-2; bool fn=false; for(int x=0;!fn&&a*x<=T;x++) { for(int y=0;!fn&&a*x+b*y<=T;y++) { int rest=T-a*x-b*y; if(rest%c!=0)continue; int z=rest/c; fn=true; for(int i=0;i<N;i++)for(int j=i+1;j<N;j++) { A[i][j]=0; if(i==0)A[i][j]+=x; A[i][j]+=y; if(i!=0)A[i][j]+=z; } } } if(fn) { cout<<"Yes"<<endl; for(int i=0;i<N;i++)for(int j=i+1;j<N;j++) { cout<<i+1<<" "<<j+1<<" "<<A[i][j]<<endl; } } else cout<<"No"<<endl; } }