結果

問題 No.2435 Order All Company
ユーザー ShirotsumeShirotsume
提出日時 2023-08-18 21:55:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,384 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 92,860 KB
最終ジャッジ日時 2023-08-18 21:56:03
合計ジャッジ時間 10,125 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
74,384 KB
testcase_01 AC 108 ms
74,040 KB
testcase_02 AC 110 ms
74,316 KB
testcase_03 AC 117 ms
74,300 KB
testcase_04 AC 125 ms
78,768 KB
testcase_05 AC 326 ms
92,156 KB
testcase_06 AC 317 ms
92,004 KB
testcase_07 AC 299 ms
86,180 KB
testcase_08 AC 312 ms
91,916 KB
testcase_09 AC 316 ms
91,936 KB
testcase_10 AC 133 ms
80,156 KB
testcase_11 WA -
testcase_12 AC 120 ms
79,000 KB
testcase_13 AC 151 ms
79,360 KB
testcase_14 AC 245 ms
91,716 KB
testcase_15 AC 257 ms
92,084 KB
testcase_16 WA -
testcase_17 AC 309 ms
92,860 KB
testcase_18 WA -
testcase_19 AC 182 ms
89,664 KB
testcase_20 AC 205 ms
90,192 KB
testcase_21 AC 220 ms
90,044 KB
testcase_22 AC 238 ms
91,536 KB
testcase_23 AC 176 ms
85,956 KB
testcase_24 AC 223 ms
91,264 KB
testcase_25 AC 237 ms
91,772 KB
testcase_26 WA -
testcase_27 AC 241 ms
91,944 KB
testcase_28 AC 224 ms
89,760 KB
testcase_29 WA -
testcase_30 AC 231 ms
91,580 KB
testcase_31 WA -
testcase_32 AC 110 ms
74,076 KB
testcase_33 WA -
testcase_34 AC 148 ms
80,104 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353
def det(n, a, mod):
    ret = 1
    for i in range(n):
        if a[i][i] == 0:
            for j in range(i + 1, n):
                if a[j][i]:
                    break
            else:
                return 0
            a[j], a[i] = a[i], a[j]
            ret *= -1
            ret %= mod

        for j in range(n):
            if i < j:
                buf = a[j][i] * (pow(a[i][i], mod - 2, mod))
                buf %= mod
                for k in range(n):
                    a[j][k] -= a[i][k] * buf

                    a[j][k] %= mod
    for i in range(n):
        ret *= a[i][i]
        ret %= mod
    return ret
n, k = mi()
E = []
for _ in range(k):
    t = ii()
    E.append([li() for _ in range(t)])

ans = 0
for bit in range(1 << k):
    A = [[0] * n for _ in range(n)]
    cnt = 0
    for i in range(k):
        if 1 & (bit >> i):
            cnt += 1
            for a, b in E[i]:
                A[a - 1][b - 1] -= 1
                A[b - 1][a - 1] -= 1
                A[a - 1][a - 1] += 1
                A[b - 1][b - 1] += 1
    p = det(n - 1, A, mod)
    ans += pow(-1, cnt + 1) * p
    ans %= mod
print(ans)

0