結果

問題 No.805 UMG
ユーザー hiragnhiragn
提出日時 2022-11-12 22:05:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,680 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 77,532 KB
最終ジャッジ日時 2023-10-12 11:42:24
合計ジャッジ時間 11,967 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,656 KB
testcase_01 AC 97 ms
76,836 KB
testcase_02 AC 93 ms
71,836 KB
testcase_03 AC 92 ms
71,916 KB
testcase_04 AC 91 ms
71,780 KB
testcase_05 AC 93 ms
71,836 KB
testcase_06 AC 92 ms
71,612 KB
testcase_07 AC 92 ms
71,784 KB
testcase_08 AC 99 ms
76,736 KB
testcase_09 AC 94 ms
71,692 KB
testcase_10 AC 93 ms
71,736 KB
testcase_11 AC 92 ms
71,612 KB
testcase_12 AC 92 ms
71,740 KB
testcase_13 AC 96 ms
76,648 KB
testcase_14 AC 93 ms
71,836 KB
testcase_15 AC 112 ms
77,056 KB
testcase_16 AC 111 ms
77,072 KB
testcase_17 AC 109 ms
76,948 KB
testcase_18 AC 118 ms
76,964 KB
testcase_19 AC 106 ms
77,080 KB
testcase_20 AC 116 ms
77,160 KB
testcase_21 AC 110 ms
77,132 KB
testcase_22 AC 110 ms
77,192 KB
testcase_23 AC 1,572 ms
77,456 KB
testcase_24 AC 1,617 ms
77,464 KB
testcase_25 AC 1,680 ms
77,400 KB
testcase_26 AC 1,592 ms
77,496 KB
testcase_27 AC 1,558 ms
77,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import itertools


def main():
    n = int(input())
    s = input()

    d = collections.defaultdict(list)
    for i, c in enumerate(s, 1):
        d[c].append(i)

    ans = 0
    for i, j in itertools.product(d['U'], d['M']):
        if i > j:
            continue
        k = 2 * j - i
        if j < k <= n and k in d['G']:
            ans += 1
    print(ans)


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