結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2016-06-10 17:12:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 504 bytes |
コンパイル時間 | 577 ms |
コンパイル使用メモリ | 64,256 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:22:05 |
合計ジャッジ時間 | 1,242 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 8 |
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:21:9: warning: 'green' may be used uninitialized [-Wmaybe-uninitialized] 21 | if (green == 0) { | ^~ main.cpp:9:13: note: 'green' was declared here 9 | int green; | ^~~~~
ソースコード
#include<iostream> #include<string> void solve() { std::string s; std::cin >> s; int green; for (int i = 0; i < s.length(); i++) { if (s[i] == 'G') green++; if (s[i] == 'R') { if (green == 0) { std::cout << "impossible" << std::endl; return ; } green--; } } if (green == 0) { std::cout << "possible" << std::endl; } else { std::cout << "impossible" << std::endl; } } int main() { int n; std::cin >> n; for (int i = 0; i < n; i++) { solve(); } return 0; }