結果

問題 No.805 UMG
コンテスト
ユーザー i_mrhj
提出日時 2019-08-06 22:53:09
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 710 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 215 ms
コンパイル使用メモリ 50,688 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-13 01:44:48
合計ジャッジ時間 1,310 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;

int
main(int argc, char **argv)
{
  int n; char s[5001];
  scanf("%d", &n);
  scanf("%s", s);

  int cnt = 0;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      if(s[i] == 'U' && s[j] == 'M'){
	if(2 * j - i < n &&s[2 * j - i] == 'G'){
	  cnt++;
	}
      }
    }
  }

  printf("%d\n", cnt);

  return 0;
}
0