結果

問題 No.1571 All Your Cycles Are Same Lengths
ユーザー the-xinthe-xin
提出日時 2021-06-27 15:18:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 66,432 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 17:24:52
合計ジャッジ時間 1,294 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0