結果

問題 No.346 チワワ数え上げ問題
ユーザー 👑 yumechiyumechi
提出日時 2016-03-08 22:03:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 526 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 209,672 KB
最終ジャッジ日時 2023-10-24 20:26:32
合計ジャッジ時間 6,944 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
61,192 KB
testcase_01 AC 45 ms
55,516 KB
testcase_02 AC 45 ms
55,516 KB
testcase_03 AC 44 ms
55,516 KB
testcase_04 AC 45 ms
55,516 KB
testcase_05 AC 45 ms
55,516 KB
testcase_06 AC 45 ms
55,516 KB
testcase_07 AC 45 ms
55,516 KB
testcase_08 AC 46 ms
55,516 KB
testcase_09 AC 46 ms
55,516 KB
testcase_10 AC 250 ms
76,460 KB
testcase_11 AC 127 ms
75,788 KB
testcase_12 AC 175 ms
76,012 KB
testcase_13 AC 111 ms
75,732 KB
testcase_14 AC 52 ms
63,400 KB
testcase_15 AC 163 ms
75,964 KB
testcase_16 AC 195 ms
76,120 KB
testcase_17 AC 244 ms
76,412 KB
testcase_18 AC 241 ms
76,504 KB
testcase_19 AC 207 ms
76,388 KB
testcase_20 AC 55 ms
69,524 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import reduce
from operator import mul

# nC2
def combi(n):
    return (n * (n-1)) // 2
    
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:
        wlen = len([0 for i in wl if i > cidx])
        if wlen < 2:
            break
        res += combi(wlen)
    print(res)

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