結果
問題 |
No.805 UMG
|
ユーザー |
|
提出日時 | 2021-09-03 00:32:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 2,117 ms |
コンパイル使用メモリ | 175,616 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 14:12:56 |
合計ジャッジ時間 | 2,878 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; const int INF = 1e+9; const ll LINF = (ll)pow(10,18); int main(){ int n; string s; cin >> n >> s; vector<bool> u(n); vector<bool> g(n); set<int> m; for(int i=0; i<n; i++){ if(s[i] == 'U') u[i] = 1; else if(s[i] == 'G') g[i] = 1; else m.insert(i); } int a,b,x; ll ans = 0; for(auto s : m){ x = min(s, n-s-1); a = s-1; b = s+1; while(x--){ if(u[a] and g[b]) ans++; a--; b++; } } cout << ans << endl; }