結果

問題 No.1482 Swap Many Permutations
ユーザー 👑 ygussanyygussany
提出日時 2021-03-28 17:18:26
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 948 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 30,592 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 22:46:55
合計ジャッジ時間 4,612 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 0 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 0 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 0 ms
5,376 KB
testcase_42 AC 12 ms
5,376 KB
testcase_43 WA -
testcase_44 AC 12 ms
5,376 KB
testcase_45 WA -
testcase_46 AC 14 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 998244353;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int main()
{
	int i, N, M, B[100001], C[100001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%d %d", &(B[i]), &(C[i]));
	
	int j;
	long long d_fact[3] = {(long long)M * (M - 1) % Mod, (long long)M * (M - 1) % Mod - 1, Mod - 1}, tmp = d_fact[0] - 2;
	printf("1\n");
	if (B[0] == B[1] && C[0] == C[1]) printf("0\n");
	else printf("%lld\n", d_fact[0]);
	for (i = 2, j = 0, d_fact[0] = d_fact[0] * div_mod(1, 2, Mod) % Mod; i < N; i++, j ^= 1) {
		d_fact[j] = d_fact[j] * (tmp--) % Mod;
		if (tmp < 0) tmp += Mod;
		if (j == 0) printf("%lld\n", d_fact[0] * d_fact[1] % Mod);
		else {
			d_fact[2] = d_fact[2] * (Mod - i) % Mod;
			printf("%lld\n", d_fact[0] * (d_fact[1] + d_fact[2]) % Mod);
		}
	}
	fflush(stdout);
	return 0;
}
0