結果

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

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int n;
string s;

int main() {
	int i, j;
	int ans = 0;
	
	cin >> n >> s;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			int k = j + (j - i);
			if (k >= n) continue;
			if (s[i] == 'U' && s[j] == 'M' && s[k] == 'G') ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
0