結果

問題 No.805 UMG
ユーザー GrayCoder
提出日時 2019-03-22 22:03:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 477 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,912 KB
実行使用メモリ 76,532 KB
最終ジャッジ日時 2024-11-18 13:24:40
合計ジャッジ時間 5,266 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect
from collections import defaultdict
from sys import stdin

def main():
    N = int(input())
    S = input()

    txt = defaultdict(list)
    for i, s in enumerate(S, start=1):
        txt[s].append(i)

    ans = 0
    for j in txt['M']:
        for i in txt['U']:
            k = j - i + j
            n = bisect(txt['G'], k)
            if txt['G'][n-1] == k:
                ans += 1
    print(ans)

input = lambda: stdin.readline().rstrip()
main()
0