結果

問題 No.2711 Connecting Lights
ユーザー budoubudou
提出日時 2024-04-07 15:42:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 43,040 KB
最終ジャッジ日時 2024-04-07 15:43:13
合計ジャッジ時間 19,407 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 505 ms
43,040 KB
testcase_01 AC 493 ms
43,040 KB
testcase_02 AC 489 ms
43,040 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 523 ms
43,040 KB
testcase_06 AC 498 ms
43,040 KB
testcase_07 AC 505 ms
43,040 KB
testcase_08 AC 518 ms
43,040 KB
testcase_09 WA -
testcase_10 AC 523 ms
43,040 KB
testcase_11 AC 502 ms
43,040 KB
testcase_12 AC 497 ms
43,040 KB
testcase_13 AC 512 ms
43,040 KB
testcase_14 AC 506 ms
43,040 KB
testcase_15 WA -
testcase_16 AC 496 ms
43,040 KB
testcase_17 AC 485 ms
43,040 KB
testcase_18 AC 516 ms
43,040 KB
testcase_19 AC 485 ms
43,040 KB
testcase_20 AC 509 ms
43,040 KB
testcase_21 AC 488 ms
43,040 KB
testcase_22 AC 507 ms
43,040 KB
testcase_23 AC 484 ms
43,040 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 485 ms
43,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import typing
import sys
# sys.setrecursionlimit(100100)
from collections import defaultdict
input = lambda: sys.stdin.readline().strip()
inf = 10**18
mod = 998244353
import numpy as np
# import heapq

def solve():
  N, M, K = map(int, input().split())
  A = [[0 for _ in range(1 << N)] for _ in range(1 << N)]
  for i in range(1 << N):
    for j in range(1 << N):
      if (i&j).bit_count() >= K:
        A[i][j] = 1
  As = [np.array(A)]
  for _ in range(15):
    As.append(As[-1]@As[-1])
    As[-1]%=mod
    
  i = 0
  if M == 1:
    print(0)
    return

  dp = sum(As[0]).reshape((-1, 1))
  Ans = np.identity(1<<N, dtype=int)
  M-=2
  while M:
    if M % 2 == 1:
      Ans = Ans@As[i]
      Ans%=mod
    M //= 2
    i += 1
    
  Ans = Ans@dp
  ans = sum(Ans)[0]%mod
  print(ans)
def main():
  t = 1
  for _ in range(t):
    solve()
main()
0