結果

問題 No.805 UMG
ユーザー hiragnhiragn
提出日時 2022-11-12 22:05:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 422 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 10,740 KB
実行使用メモリ 13,196 KB
最終ジャッジ日時 2023-10-12 11:41:59
合計ジャッジ時間 5,395 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
12,816 KB
testcase_01 AC 19 ms
8,584 KB
testcase_02 AC 18 ms
8,504 KB
testcase_03 AC 18 ms
8,552 KB
testcase_04 AC 19 ms
8,544 KB
testcase_05 AC 18 ms
8,540 KB
testcase_06 AC 18 ms
8,552 KB
testcase_07 AC 19 ms
8,564 KB
testcase_08 AC 18 ms
8,460 KB
testcase_09 AC 18 ms
8,620 KB
testcase_10 AC 19 ms
8,552 KB
testcase_11 AC 19 ms
8,500 KB
testcase_12 AC 19 ms
8,568 KB
testcase_13 AC 19 ms
8,424 KB
testcase_14 AC 19 ms
8,504 KB
testcase_15 AC 91 ms
8,432 KB
testcase_16 AC 80 ms
8,472 KB
testcase_17 AC 51 ms
8,472 KB
testcase_18 AC 128 ms
8,480 KB
testcase_19 AC 42 ms
8,488 KB
testcase_20 AC 119 ms
8,624 KB
testcase_21 AC 64 ms
8,480 KB
testcase_22 AC 80 ms
8,480 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

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