結果

問題 No.154 市バス
ユーザー hogekihogeki
提出日時 2017-07-16 23:22:06
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,634 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 109,712 KB
実行使用メモリ 33,092 KB
最終ジャッジ日時 2024-04-21 10:17:32
合計ジャッジ時間 1,791 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
31,048 KB
testcase_01 AC 43 ms
26,956 KB
testcase_02 AC 43 ms
31,048 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 38 ms
29,004 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Problem154
{
    class Program
    {
        static void Main(string[] args)
        {
            int T = int.Parse(Console.ReadLine());

            string[] S = new string[T];
            for (int i = 0; i < T; i++)
                S[i] = Console.ReadLine();

            for(int i = 0; i < T; i++)
            {
                int wcount = 0;
                int gcount = 0;
                foreach(char s in S[i])
                {
                    if (s == 'W')
                    {
                        wcount++;
                    }
                    else if(s == 'G')
                    {
                        if(--wcount < 0)
                        {
                            Console.WriteLine("impossible");
                            break;
                        }
                        else
                        {
                            gcount++;
                        }
                    }
                    else if(s == 'R')
                    {
                        if(--gcount < 0)
                        {
                            Console.WriteLine("impossible");
                            break;
                        }
                    }
                }

                if(gcount == 0)
                {
                    Console.WriteLine("possible");
                }
                else if(gcount > 0)
                {
                    Console.WriteLine("impossible");
                }
            }

        }
    }
}
0