結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:08:24 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 39 ms / 2,000 ms |
| + 375µs | |
| コード長 | 384 bytes |
| 記録 | |
| コンパイル時間 | 461 ms |
| コンパイル使用メモリ | 64,272 KB |
| 実行使用メモリ | 58,980 KB |
| 最終ジャッジ日時 | 2026-10-29 17:17:52 |
| 合計ジャッジ時間 | 2,992 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
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