結果
| 問題 |
No.805 UMG
|
| コンテスト | |
| ユーザー |
gazelle
|
| 提出日時 | 2019-03-22 21:24:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 1,047 bytes |
| コンパイル時間 | 1,078 ms |
| コンパイル使用メモリ | 113,592 KB |
| 最終ジャッジ日時 | 2025-01-06 23:41:35 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
string s;
cin >> n >> s;
ll ans = 0;
REP(i, n) {
if(s[i] != 'M') continue;
for(ll j = 1; j <= n; j++) {
ll a = i - j, b = i + j;
if(a < 0 || b >= n) break;
if(s[a] == 'U' && s[b] == 'G') ans++;
}
}
cout << ans << endl;
return 0;
}
/* --------------------------------------- */
gazelle