結果

問題 No.2772 Appearing Even Times
ユーザー 👑 timitimi
提出日時 2024-06-03 00:14:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,866 ms / 4,000 ms
コード長 752 bytes
コンパイル時間 421 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-06-03 00:14:29
合計ジャッジ時間 23,449 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
64,768 KB
testcase_01 AC 64 ms
65,536 KB
testcase_02 AC 60 ms
64,768 KB
testcase_03 AC 60 ms
65,408 KB
testcase_04 AC 61 ms
65,280 KB
testcase_05 AC 61 ms
65,536 KB
testcase_06 AC 62 ms
65,024 KB
testcase_07 AC 39 ms
51,968 KB
testcase_08 AC 1,170 ms
76,160 KB
testcase_09 AC 1,512 ms
76,032 KB
testcase_10 AC 50 ms
60,544 KB
testcase_11 AC 69 ms
65,408 KB
testcase_12 AC 1,839 ms
76,032 KB
testcase_13 AC 1,794 ms
76,288 KB
testcase_14 AC 1,787 ms
76,416 KB
testcase_15 AC 1,821 ms
76,288 KB
testcase_16 AC 1,866 ms
76,288 KB
testcase_17 AC 1,821 ms
76,160 KB
testcase_18 AC 1,796 ms
76,032 KB
testcase_19 AC 1,841 ms
76,032 KB
testcase_20 AC 1,845 ms
76,288 KB
testcase_21 AC 1,783 ms
76,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
U=[0 for i in range(1<<10)]
T=[0 for i in range(1<<10)]
NU=[0 for _ in range(1<<10)]
NT=[0 for _ 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
  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
  for j in range(1,10):
    NU[1<<j]+=1
  U,NU,T,NT=NU,U,NT,T
  for bit in range(1<<10):
    NU[bit]=0;NT[bit]=0
  
        
ans=U[0]%mod
if sum(C)==0:
  print((ans+1)%mod)
else:
  print(ans)
  
0