結果
| 問題 | 
                            No.805 UMG
                             | 
                    
| コンテスト | |
| ユーザー | 
                             pasoconhoshii
                         | 
                    
| 提出日時 | 2019-03-23 09:01:17 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 140 ms / 2,000 ms | 
| コード長 | 325 bytes | 
| コンパイル時間 | 238 ms | 
| コンパイル使用メモリ | 82,468 KB | 
| 実行使用メモリ | 65,372 KB | 
| 最終ジャッジ日時 | 2024-11-18 13:30:35 | 
| 合計ジャッジ時間 | 2,622 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
ソースコード
N = int(input())
S = input()
ans = 0
for stride in range(1, N//2+1):
    for k in range(0+stride, N-stride+1):
        i = k - stride
        j = k + stride
        if j >= N:
            continue
        
        if S[i] == "U" and \
           S[k] == "M" and \
           S[j] == "G":
               ans += 1
print(ans)
            
            
            
        
            
pasoconhoshii