結果

問題 No.346 チワワ数え上げ問題
ユーザー gahougahou
提出日時 2016-11-07 16:07:15
言語 Python2
(2.7.18)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 6,784 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-05-03 22:39:28
合計ジャッジ時間 2,100 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,144 KB
testcase_01 AC 11 ms
6,144 KB
testcase_02 AC 11 ms
6,016 KB
testcase_03 AC 10 ms
6,144 KB
testcase_04 AC 12 ms
6,016 KB
testcase_05 AC 11 ms
6,272 KB
testcase_06 AC 12 ms
6,144 KB
testcase_07 AC 11 ms
6,144 KB
testcase_08 AC 12 ms
6,016 KB
testcase_09 AC 12 ms
6,272 KB
testcase_10 AC 95 ms
9,600 KB
testcase_11 AC 62 ms
8,064 KB
testcase_12 AC 77 ms
8,832 KB
testcase_13 AC 55 ms
7,808 KB
testcase_14 AC 15 ms
6,272 KB
testcase_15 AC 72 ms
8,576 KB
testcase_16 AC 80 ms
8,960 KB
testcase_17 AC 94 ms
9,472 KB
testcase_18 AC 95 ms
9,600 KB
testcase_19 AC 83 ms
8,960 KB
testcase_20 AC 97 ms
11,776 KB
testcase_21 AC 107 ms
13,056 KB
testcase_22 AC 107 ms
12,928 KB
testcase_23 AC 11 ms
6,144 KB
testcase_24 AC 11 ms
6,016 KB
testcase_25 AC 11 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=raw_input()
dp=[[0]*len(S) for _ in xrange(4)]
if S[0]=="c": dp[1][0]=1
dp[0][0]=1
for i in xrange(1,len(S)):
  dp[0][i] = dp[0][i-1]
  if S[i]=="c":
    dp[1][i] = dp[0][i-1]+dp[1][i-1]
    dp[2][i] = dp[2][i-1]
    dp[3][i] = dp[3][i-1]
  elif S[i]=="w":
    dp[1][i] = dp[1][i-1]
    dp[2][i] = dp[1][i-1]+dp[2][i-1]
    dp[3][i] = dp[2][i-1]+dp[3][i-1]
  else:
    dp[1][i] = dp[1][i-1]
    dp[2][i] = dp[2][i-1]
    dp[3][i] = dp[3][i-1]
print dp[3][len(S)-1]
0