結果

問題 No.805 UMG
ユーザー calei
提出日時 2020-01-22 14:21:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 896 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-11-18 13:57:17
合計ジャッジ時間 6,032 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

# yukicoder No.805 UMG 2020/01/22

n=int(input())
s=input()

U,M,G=set(),set(),set()
for i,e in enumerate(s,1):
    if e=='U':
        U.add(i)
    elif e=='M':
        M.add(i)
    else:
        G.add(i)
else:
    if not(U and M and G):
        print(0)
        exit()
cnt=0
for u in U:
    for m in M:
        if u>m:continue
        g=m+m-u
        if not(u<m<g):continue
        if m+m-u in G:
            cnt+=1
print(cnt)
0