結果
問題 | No.805 UMG |
ユーザー |
![]() |
提出日時 | 2019-03-22 21:27:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 582 bytes |
コンパイル時間 | 774 ms |
コンパイル使用メモリ | 73,960 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 13:13:19 |
合計ジャッジ時間 | 1,775 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>#include <cstdio>#include <cstring>#include <cmath>using namespace std;using ll = long long;int main() {ios::sync_with_stdio(false);cin.tie(0);int n;cin >> n;string s;cin >> s;int r = 0;for (int i = 0; i < n; i++) {if (s[i] == 'M') {int m = min(i, n - 1 - i);for (int h = 1; h <= m; h++) {if (s[i - h] == 'U' && s[i + h] == 'G') r++;}}}cout << r << endl;return 0;}