結果

問題 No.805 UMG
ユーザー 学ぶマン
提出日時 2025-07-06 14:39:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 82,192 KB
実行使用メモリ 75,964 KB
最終ジャッジ日時 2025-07-06 14:39:51
合計ジャッジ時間 3,539 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.set_int_max_str_digits(0)
N = int(input())
S = input()

ans = 0
for i, s in enumerate(S):
    if s == 'M':
        for j in range(1, N):
            if 0 <= i - j and i + j < N:
                l, r = S[i - j], S[i + j]
                if l == 'U' and r == 'G':
                    ans += 1
            else:
                break
print(ans)
0