結果

問題 No.1171 Runs in Subsequences
ユーザー googol_S0googol_S0
提出日時 2020-08-15 10:30:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 288 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 77,876 KB
最終ジャッジ日時 2024-04-18 23:50:43
合計ジャッジ時間 3,093 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,568 KB
testcase_01 AC 36 ms
53,288 KB
testcase_02 AC 37 ms
52,064 KB
testcase_03 AC 35 ms
52,144 KB
testcase_04 AC 36 ms
52,000 KB
testcase_05 AC 40 ms
52,196 KB
testcase_06 AC 37 ms
52,424 KB
testcase_07 AC 37 ms
52,804 KB
testcase_08 AC 38 ms
52,808 KB
testcase_09 AC 44 ms
52,360 KB
testcase_10 AC 41 ms
53,916 KB
testcase_11 AC 39 ms
53,820 KB
testcase_12 AC 37 ms
53,440 KB
testcase_13 AC 40 ms
53,884 KB
testcase_14 AC 40 ms
53,072 KB
testcase_15 AC 213 ms
74,564 KB
testcase_16 AC 213 ms
74,248 KB
testcase_17 AC 225 ms
77,876 KB
testcase_18 AC 225 ms
77,584 KB
testcase_19 AC 221 ms
75,972 KB
testcase_20 AC 219 ms
76,256 KB
testcase_21 AC 223 ms
76,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
N=len(S)
X=[[] for i in range(26)]
for i in range(N):
  X[ord(S[i])-ord('a')].append(i)
P=0
Q=0
mod=10**9+7
for i in range(26):
  Q=0
  for j in range(len(X[i])):
    if j:
      P=(P+Q*pow(2,N-1-X[i][j],mod))%mod
    Q=(Q+pow(2,X[i][j],mod))%mod
print((pow(2,N-1,mod)*N-P)%mod)
0