結果

問題 No.805 UMG
ユーザー hogeover30
提出日時 2019-03-22 21:27:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 287 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 67,292 KB
最終ジャッジ日時 2025-01-06 23:43:27
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n; cin>>n;
    string s; cin>>s;

    long res=0;
    for(int i=0; i+2<n; ++i) if (s[i]=='U')
        for(int k=1; i+k+k<n; ++k) if (s[i+k]=='M' and s[i+k+k]=='G')
            ++res;
    cout<<res<<endl;
}
0