結果
問題 |
No.805 UMG
|
ユーザー |
|
提出日時 | 2019-03-22 22:04:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 727 bytes |
コンパイル時間 | 790 ms |
コンパイル使用メモリ | 86,976 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 13:24:55 |
合計ジャッジ時間 | 1,611 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 2 WA * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:17: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized] 27 | cout << ans << endl; | ^~~
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <map> #include <set> #include <stack> #include <cmath> #include <queue> #include <limits> #include <iomanip> using namespace std; int main() { int n; int ans; string s; cin >> n; cin >> s; vector<int>M; for(int i = 0; i < n; i++){ if(s[i] == 'M') M.push_back(i); } if(M.size() == 0) { cout << ans << endl; return 0; } for(int i = 0; i < M.size(); i++) { int center = M[i]; int d = 1; while(M[i] - d >= 0 || M[i] + d < n) { if(s[M[i]-d] == 'U' && s[M[i]+d] =='G') ans += 1; d++; } } cout << ans << endl; }