結果

問題 No.805 UMG
ユーザー to10to10to10to
提出日時 2019-04-10 21:58:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 166,588 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-18 13:43:55
合計ジャッジ時間 2,583 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

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

  int cnt=0;
  rep(i,n){
    reps(j,i+1,n){
      int k=2*j-i;
      if(k<n && s[i]=='U' && s[j]=='M'){
        if(s[k] == 'G'){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}
0