結果

問題 No.154 市バス
ユーザー しらゆきしらゆき
提出日時 2015-12-31 09:59:50
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,118 bytes
コンパイル時間 1,012 ms
コンパイル使用メモリ 111,796 KB
実行使用メモリ 32,692 KB
最終ジャッジ日時 2024-04-21 09:01:19
合計ジャッジ時間 1,881 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
22,400 KB
testcase_01 AC 67 ms
22,528 KB
testcase_02 AC 66 ms
22,656 KB
testcase_03 AC 64 ms
22,272 KB
testcase_04 WA -
testcase_05 AC 23 ms
17,920 KB
testcase_06 AC 21 ms
17,920 KB
testcase_07 AC 77 ms
22,016 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.Linq;

class Program
{
    static void Main()
    {
        int t = int.Parse(Console.ReadLine());

        for (int i=0;i< t; i++)
        {
            int g = 0, r = 0;
            string s = Console.ReadLine();
            int cnt = s.Length - s.Replace("G","").Length;
            for (int j=0; j < s.Length; j++)
            {
                if (s[j] == 'G') g++;
                if (s[j] == 'R') r++;
                if (g == cnt && s[j] == 'W')
                {
                    Console.WriteLine("impossible");
                    break;
                }
                if (r > g)
                {
                    Console.WriteLine("impossible");
                    break;
                }
                if (j == s.Length - 1)
                {
                    if (r == g)
                    {
                        if (!(s[j] == 'R')) Console.WriteLine("impossible");
                        else Console.WriteLine("possible");
                    }
                    else Console.WriteLine("impossible");
                }
            }
        }
    }
}
0