結果
| 問題 | No.805 UMG |
| コンテスト | |
| ユーザー |
hagyu_aya
|
| 提出日時 | 2019-03-22 21:31:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 851 bytes |
| コンパイル時間 | 1,247 ms |
| コンパイル使用メモリ | 159,816 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-18 13:14:25 |
| 合計ジャッジ時間 | 2,062 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
using namespace std;
using ll = long long;
using pii = pair<int, int>;
constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18
const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(10);
int n; string s;
cin >> n >> s;
ll ans = 0;
for(int i = 0; i < n; ++i){
for(int j = 1; i - j >= 0 && i + j < n; ++j){
if(s[i - j] == 'U' && s[i] == 'M' && s[i + j] == 'G') ++ans;
}
}
cout << ans << "\n";
return 0;
}
hagyu_aya