結果
問題 |
No.805 UMG
|
ユーザー |
|
提出日時 | 2019-03-23 09:07:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 431 bytes |
コンパイル時間 | 2,082 ms |
コンパイル使用メモリ | 193,504 KB |
最終ジャッジ日時 | 2025-01-07 00:08:55 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); 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 < n; j++) { if (i - j < 0 || i + j >= n) break; ans += s[i - j] == 'U' && s[i + j] == 'G'; } } } cout << ans << endl; return 0; }