結果

問題 No.346 チワワ数え上げ問題
ユーザー 👑 yumechiyumechi
提出日時 2016-03-08 22:06:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 487 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 279,728 KB
最終ジャッジ日時 2023-10-24 20:29:16
合計ジャッジ時間 5,220 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
60,536 KB
testcase_01 AC 36 ms
53,524 KB
testcase_02 AC 35 ms
53,524 KB
testcase_03 AC 35 ms
53,524 KB
testcase_04 AC 35 ms
53,524 KB
testcase_05 AC 34 ms
53,524 KB
testcase_06 AC 35 ms
53,524 KB
testcase_07 AC 34 ms
53,524 KB
testcase_08 AC 35 ms
53,524 KB
testcase_09 AC 35 ms
53,524 KB
testcase_10 AC 112 ms
76,564 KB
testcase_11 AC 71 ms
75,476 KB
testcase_12 AC 86 ms
75,920 KB
testcase_13 AC 69 ms
75,428 KB
testcase_14 AC 39 ms
59,396 KB
testcase_15 AC 85 ms
75,772 KB
testcase_16 AC 97 ms
76,044 KB
testcase_17 AC 111 ms
76,572 KB
testcase_18 AC 108 ms
76,516 KB
testcase_19 AC 92 ms
76,096 KB
testcase_20 AC 43 ms
65,528 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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:
        wl = [i for i in wl if i > cidx]
        wlen = len(wl)
        if wlen < 2:
            break
        res += combi(wlen)
    print(res)

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