結果

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

ソースコード

diff #

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

int main() {
  i64 N;
  cin >> N;
  string s;
  cin >> s;
  i64 ans = 0;
  for(int c = 0;c < N;c++) {
    if(s[c] == 'M') {
      for(int i = 1;c - i >= 0 && c + i < N;i++) {
        if(s[c - i] == 'U' && s[c + i] == 'G') ans++;
      }
    }
  }
  cout << ans << endl;
}
0