結果

問題 No.346 チワワ数え上げ問題
ユーザー 👑 yumechiyumechi
提出日時 2016-03-08 22:09:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 441 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 81,608 KB
実行使用メモリ 280,416 KB
最終ジャッジ日時 2023-10-24 20:30:53
合計ジャッジ時間 5,409 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
60,472 KB
testcase_01 AC 37 ms
53,456 KB
testcase_02 AC 37 ms
53,456 KB
testcase_03 AC 37 ms
53,456 KB
testcase_04 AC 37 ms
53,456 KB
testcase_05 AC 37 ms
53,456 KB
testcase_06 AC 37 ms
53,456 KB
testcase_07 AC 38 ms
53,456 KB
testcase_08 AC 37 ms
53,456 KB
testcase_09 AC 38 ms
53,456 KB
testcase_10 AC 134 ms
76,508 KB
testcase_11 AC 84 ms
75,352 KB
testcase_12 AC 105 ms
75,772 KB
testcase_13 AC 76 ms
75,296 KB
testcase_14 AC 42 ms
59,276 KB
testcase_15 AC 97 ms
75,652 KB
testcase_16 AC 113 ms
75,920 KB
testcase_17 AC 133 ms
76,452 KB
testcase_18 AC 129 ms
76,388 KB
testcase_19 AC 114 ms
75,992 KB
testcase_20 AC 46 ms
65,416 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    s = input()
    cl, wl = [], []

    slen = len(s)
    for i in range(slen):
        if s[i] == "c":
            cl.append(i)
            continue
        elif s[i] == "w":
            wl.append(i)

    res = 0
    for cidx in cl:
        wl = [i for i in wl if i > cidx]
        wlen = len(wl)
        if wlen < 2:
            break
        res += (wlen * (wlen-1)) // 2
    print(res)

if __name__=="__main__":
    solve()
0