結果

問題 No.805 UMG
ユーザー dgd1724
提出日時 2019-04-05 05:46:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 476 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 60,104 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 13:38:42
合計ジャッジ時間 1,466 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <fstream>
#include <iostream>
#include <string>


int main() {

	//std::ifstream inf("Text.txt");	std::cin.rdbuf(inf.rdbuf());

	int N;
	std::cin >> N;

	std::string S;
	std::cin >> S;

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'U') {
			for (int j = i + 1; j < N; j++) {
				if (S[j] == 'M') {
					if (j + j - i < N) {
						if (S[j + j - i] == 'G') {
							ans++;
						}
					}
				}
			}
		}
	}

	std::cout << ans << std::endl;
	
	return 0;

}
0