結果
問題 | No.805 UMG |
ユーザー |
![]() |
提出日時 | 2019-03-22 21:38:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 461 bytes |
コンパイル時間 | 489 ms |
コンパイル使用メモリ | 67,900 KB |
最終ジャッジ日時 | 2025-01-06 23:46:52 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include<iostream> #include<string> int main() { int n; std::string s; std::cin >> n; std::cin >> s; int ans = 0; for (int i = 0, len = s.size(); i < len; i++) { if (s[i] != 'U') continue; for (int j = i + 1; j < len; j++) { if (s[j] != 'M') continue; int k = j + (j - i); if (len <= k) break; if (s[k] == 'G') ans++; } } std::cout << ans << std::endl; }