結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-23 13:40:04 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 2,000 ms |
| コード長 | 415 bytes |
| コンパイル時間 | 235 ms |
| コンパイル使用メモリ | 7,040 KB |
| 実行使用メモリ | 9,472 KB |
| 最終ジャッジ日時 | 2024-11-24 01:54:59 |
| 合計ジャッジ時間 | 1,904 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
S = raw_input()
c_index = [i for i in xrange(len(S)) if S[i] == 'c']
w_index = [i for i in xrange(len(S)) if S[i] == 'w']
if len(c_index) == 0 or len(w_index) == 0:
print 0
exit()
wp = 0
ans = 0
for c in c_index:
if wp >= len(w_index):
break
while w_index[wp] < c:
wp += 1
if wp >= len(w_index):
break
ans += (len(w_index)-wp)*(len(w_index)-wp-1)/2
print ans