結果
問題 |
No.2561 みんな大好きmod 998
|
ユーザー |
![]() |
提出日時 | 2023-11-06 00:41:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,145 ms / 4,000 ms |
コード長 | 584 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 423,040 KB |
最終ジャッジ日時 | 2024-09-25 22:55:23 |
合計ジャッジ時間 | 15,178 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 |
ソースコード
# 非再帰BFS (K個目をqに入れて取り出した時に判定) from collections import deque N,K = map(int,input().split()) assert 1 <= N <= 28 assert 1 <= K <= min(8,N) A = list(map(int,input().split())) for a in A: assert 0 <= a <= 998244352 ans = 0 # [i,l,s]: i個選んだ,今まで選んだ数字のうち一番後ろのindexはl,和はs q = deque([[0,-1,0]]) while q: i,l,s = q.popleft() if i == K: if s % 998244353 <= s % 998: ans += 1 continue for j in range(l+1,N-K+1+i): q.append([i+1,j,s+A[j]]) print(ans % 998)