結果

問題 No.2772 Appearing Even Times
ユーザー 👑 timitimi
提出日時 2024-06-02 23:48:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,843 ms / 4,000 ms
コード長 707 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2024-06-02 23:48:50
合計ジャッジ時間 23,212 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
64,640 KB
testcase_01 AC 58 ms
65,664 KB
testcase_02 AC 57 ms
64,896 KB
testcase_03 AC 56 ms
65,408 KB
testcase_04 AC 57 ms
65,152 KB
testcase_05 AC 58 ms
65,408 KB
testcase_06 AC 57 ms
65,280 KB
testcase_07 AC 35 ms
51,840 KB
testcase_08 AC 1,172 ms
76,672 KB
testcase_09 AC 1,458 ms
77,056 KB
testcase_10 AC 48 ms
60,672 KB
testcase_11 AC 59 ms
65,664 KB
testcase_12 AC 1,837 ms
76,928 KB
testcase_13 AC 1,843 ms
76,800 KB
testcase_14 AC 1,764 ms
76,672 KB
testcase_15 AC 1,782 ms
76,800 KB
testcase_16 AC 1,832 ms
76,800 KB
testcase_17 AC 1,818 ms
76,928 KB
testcase_18 AC 1,779 ms
76,928 KB
testcase_19 AC 1,810 ms
77,056 KB
testcase_20 AC 1,745 ms
77,028 KB
testcase_21 AC 1,760 ms
77,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
U=[0 for i in range(1<<10)]
T=[0 for i in range(1<<10)]
C=[0]*10;mod=998244353
s=int(S[0]) 
C[s]+=1

for i in range(1,int(S[0])+1):
  if i!=int(S[0]):
    U[1<<i]+=1
  else:
    T[1<<i]+=1
    
for i in range(1,len(S)):
  s=int(S[i]) 
  C[s]+=1
  C[s]%=2
  NU=[0 for _ in range(1<<10)]
  NT=[0 for _ in range(1<<10)]
  for bit in range(1<<10):
    for k in range(10):
      nex=bit^(1<<k)
      NU[nex]+=U[bit]
      NU[nex]%=mod 
      if k==s:
        NT[nex]+=T[bit]
        NT[nex]%=mod
      elif k<s:
        NU[nex]+=T[bit]
        NU[nex]%=mod
  if i!=0:
    for j in range(1,10):
      NU[1<<j]+=1
  U=NU;T=NT
        
ans=U[0]%mod
if sum(C)==0:
  print((ans+1)%mod)
else:
  print(ans)
  
0