結果

問題 No.1571 All Your Cycles Are Same Lengths
ユーザー 👑 ygussanyygussany
提出日時 2021-06-27 13:35:04
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 556 ms
コンパイル使用メモリ 28,924 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 17:38:11
合計ジャッジ時間 2,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int main()
{
	int i, j, k, q, Q, N, T, w[10] = {};
	scanf("%d", &Q);
	for (q = 1; q <= Q; q++) {
		scanf("%d %d", &N, &T);
		if (T % 2 != 0 && (T < N || N % 2 == 0)) {
			if (N % 2 != 0 && T == N - 2) {
				printf("Yes\n");
				for (j = 2; j <= N; j++) printf("1 %d 0\n", j);
				for (i = 2; i <= N; i++) for (j = i + 1; j <= N; j++) printf("%d %d 1\n", i, j);
				continue;
			}
			printf("No\n");
			continue;
		} else printf("Yes\n");
		if (T % 2 == 0) {
			k = 0;
			w[1] = T / 2;
		} else {
			k = 1;
			w[1] = (T - N) / 2;
		}
		for (i = 1; i <= N; i++) for (j = i + 1; j <= N; j++) printf("%d %d %d\n", i, j, k + w[i] + w[j]);
	}
	fflush(stdout);
	return 0;
}
0