結果
問題 | No.805 UMG |
ユーザー |
|
提出日時 | 2020-04-10 13:17:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 494 bytes |
コンパイル時間 | 1,121 ms |
コンパイル使用メモリ | 66,944 KB |
最終ジャッジ日時 | 2025-01-09 15:39:40 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <iostream> #include <string> void solve() { int n; std::string s; std::cin >> n >> s; int ans = 0; for (int l = 1; l < n; ++l) { for (int i = 0; i + l * 2 < n; ++i) { int j = i + l, k = i + l * 2; if (s[i] == 'U' && s[j] == 'M' && s[k] == 'G') ++ans; } } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }