結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:08:24 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 384 bytes |
| 記録 | |
| コンパイル時間 | 216 ms |
| コンパイル使用メモリ | 96,232 KB |
| 実行使用メモリ | 84,504 KB |
| 最終ジャッジ日時 | 2026-07-07 12:54:47 |
| 合計ジャッジ時間 | 3,460 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
s = input().strip()
n = len(s)
count_w = [0] * n
current = 0
# Precompute the number of 'w's to the right of each position
for i in reversed(range(n)):
count_w[i] = current
if s[i] == 'w':
current += 1
ans = 0
# Calculate the number of valid "cww" subsequences
for i in range(n):
if s[i] == 'c':
k = count_w[i]
ans += k * (k - 1) // 2
print(ans)
lam6er