結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int solve(int N, string S){
    int count = 0;
    for (int i = 0; i < N; ++i){
        if (S[i] != 'U') continue;
        for (int s = 1; i + s + s < N; ++s){
            int j = i + s;
            int k = j + s;
            if (S[j] == 'M' and S[k] == 'G') count++;
        }
    }
    return count;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    cout << solve(N, S) << endl;
    return 0;
}
0