結果

問題 No.154 市バス
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-24 20:33:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 2,232 ms
コンパイル使用メモリ 193,660 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 14:00:28
合計ジャッジ時間 3,207 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
5,248 KB
testcase_01 AC 28 ms
5,376 KB
testcase_02 AC 27 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 27 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 24 ms
5,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:23:18: warning: 'l' may be used uninitialized [-Wmaybe-uninitialized]
   23 |         if (!f||l!='G') {
      |                 ~^~~~~
main.cpp:13:14: note: 'l' was declared here
   13 |         char l;
      |              ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int t;
    cin>>t;
    while (t--) {
        string s;
        cin>>s;
        int w=0,g=0,r=0;
        bool f=true;
        char l;
        for (char c:s) {
            if (c=='W') w++,l=c;
            else if (c=='G') g++,l=c;
            else r++;
            if (w<g||g<r) {
                f=false;
                break;
            }
        }
        if (!f||l!='G') {
            puts("impossible");
        } else {
            puts("possible");
        }
    }
    return 0;
}
0