結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-01 03:33:57 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 2,000 ms |
| コード長 | 312 bytes |
| コンパイル時間 | 206 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 14,592 KB |
| 最終ジャッジ日時 | 2024-10-13 20:26:14 |
| 合計ジャッジ時間 | 2,067 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
def main():
S = input()
N = len(S)
cnt_w = [0] * N
for i in range(N-1, -1, -1):
cnt_w[i] = (0 if i == N-1 else cnt_w[i + 1]) + (1 if S[i] == 'w' else 0)
ans = 0
for i in range(N-1):
if S[i] == 'c':
ans += cnt_w[i+1] * (cnt_w[i+1]-1) // 2
print(ans)
main()