結果
問題 | No.805 UMG |
ユーザー |
![]() |
提出日時 | 2019-03-22 21:54:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 405 bytes |
コンパイル時間 | 1,749 ms |
コンパイル使用メモリ | 192,876 KB |
最終ジャッジ日時 | 2025-01-06 23:49:19 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int n;cin >> n;string s;cin >> s;int ans = 0;for (int i = 0; i < n; i++) {if (s[i] == 'M') {for (int j = 1; j <= i; j++) {if (i - j < 0 || i + j >= n) break;if (s[i - j] == 'U' && s[i + j] == 'G') ans++;}}}cout << ans << endl;}