結果

問題 No.154 市バス
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-24 20:36:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 197,352 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-04 16:05:02
合計ジャッジ時間 2,645 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
4,380 KB
testcase_01 AC 24 ms
4,384 KB
testcase_02 AC 23 ms
4,380 KB
testcase_03 AC 23 ms
4,376 KB
testcase_04 AC 24 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 20 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:23:21: 警告: ‘l’ may be used uninitialized [-Wmaybe-uninitialized]
   23 |         if (!f||g!=r||l!='G') {
      |             ~~~~~~~~^~~~~~~~
main.cpp:13:14: 備考: ‘l’ はここで定義されています
   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||g!=r||l!='G') {
            puts("impossible");
        } else {
            puts("possible");
        }
    }
    return 0;
}
0