結果

問題 No.346 チワワ数え上げ問題
ユーザー FromBooskaFromBooska
提出日時 2023-10-18 11:36:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 85,812 KB
最終ジャッジ日時 2023-10-18 11:36:23
合計ジャッジ時間 2,846 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
60,000 KB
testcase_01 AC 43 ms
59,468 KB
testcase_02 AC 39 ms
53,468 KB
testcase_03 AC 39 ms
53,468 KB
testcase_04 AC 45 ms
59,992 KB
testcase_05 AC 39 ms
53,468 KB
testcase_06 AC 44 ms
59,988 KB
testcase_07 AC 43 ms
59,468 KB
testcase_08 AC 45 ms
59,988 KB
testcase_09 AC 45 ms
59,988 KB
testcase_10 AC 76 ms
85,780 KB
testcase_11 AC 56 ms
73,228 KB
testcase_12 AC 72 ms
83,556 KB
testcase_13 AC 55 ms
72,928 KB
testcase_14 AC 48 ms
62,264 KB
testcase_15 AC 71 ms
82,884 KB
testcase_16 AC 73 ms
83,928 KB
testcase_17 AC 76 ms
85,684 KB
testcase_18 AC 75 ms
85,756 KB
testcase_19 AC 73 ms
84,296 KB
testcase_20 AC 54 ms
74,016 KB
testcase_21 AC 74 ms
85,812 KB
testcase_22 AC 75 ms
85,812 KB
testcase_23 AC 38 ms
53,476 KB
testcase_24 AC 38 ms
53,476 KB
testcase_25 AC 38 ms
53,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# dp[i][c count, cw count, cww count]

S = input()
N = len(S)

dp = [[0]*3 for i in range(N+1)]

for i in range(1, N+1):
    s = S[i-1]
    for j in range(3):
        dp[i][j] += dp[i-1][j]
    
    if s == 'c':
        dp[i][0] += 1
    elif s == 'w':
        dp[i][1] += dp[i-1][0]
        dp[i][2] += dp[i-1][1]
    #print(dp[i])

ans = dp[N][2]
print(ans)
0