結果

問題 No.805 UMG
ユーザー chacoder1
提出日時 2021-03-08 20:22:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 391 bytes
コンパイル時間 1,718 ms
コンパイル使用メモリ 192,880 KB
最終ジャッジ日時 2025-01-19 12:58:02
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cnt=0;
  rep(i,n){
    if(s.at(i) !='U') continue;
    for(int j=i+1;j<n;j++){
      if(s.at(j) !='M') continue;
      if(j*2-i<n && s.at(j*2-i)=='G') cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}
0