結果

問題 No.805 UMG
ユーザー ooaiu
提出日時 2025-07-10 02:02:21
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 4,070 ms
コンパイル使用メモリ 272,784 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-07-10 02:02:27
合計ジャッジ時間 4,316 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for(int i = 0; i < N; i++) {
		for(int j = i + 1; j < N; j++) {
			int k = 2*j - i;
			if(j >= 0 && S[i] == 'U' && S[j] == 'M' && S[k] == 'G') {
				ans += 1;
			}
		}
	}
	cout << ans << endl;
}
0