結果

問題 No.805 UMG
ユーザー greentea011
提出日時 2019-03-27 14:42:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 65,396 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 13:35:45
合計ジャッジ時間 1,256 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;
    int ans=0;
    for (int i=1;i<=n;i++) {
        if (s[i-1]=='U') {
            for (int j=i+1;j<=(n-i)/2+i;j++) {
                ans=((s[j-1]=='M')&&(s[2*j-i-1]=='G'))?ans+1:ans;
            }
        }
    }
    std::cout << ans << std::endl;
}
0