結果

問題 No.805 UMG
コンテスト
ユーザー GrayCoder
提出日時 2019-03-22 22:03:28
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 477 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 194 ms
コンパイル使用メモリ 85,852 KB
実行使用メモリ 81,408 KB
最終ジャッジ日時 2026-05-13 01:16:21
合計ジャッジ時間 3,884 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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