結果

問題 No.154 市バス
ユーザー 14番14番
提出日時 2016-04-23 16:41:12
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,708 bytes
コンパイル時間 2,791 ms
コンパイル使用メモリ 104,320 KB
実行使用メモリ 21,888 KB
最終ジャッジ日時 2024-04-21 09:27:21
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 21 ms
17,536 KB
testcase_06 AC 20 ms
17,408 KB
testcase_07 AC 46 ms
21,504 KB
testcase_08 AC 20 ms
17,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Text;
using System.Linq;
 
class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int queryCount = int.Parse(Reader.ReadLine());
        
        for(int i=0; i<queryCount; i++) {
            Console.WriteLine(GetAns(Reader.ReadLine()));
        }

    }
    
    private string GetAns(string inpt) {
        int wCount = 0;
        int gCount = 0;
        int rCount = 0;
        int rosen = 1;
        bool isPossible = true;
        foreach (char c in inpt.ToUpper())
        {
            if(c == 'W') {
                if(gCount == rosen) {
                    rosen++;
                }
                wCount++;
            } else if(c == 'R')
            {
                rCount++;
                if(gCount < rCount) {
                    isPossible = false;
                }
            } else if(c == 'G')
            {
                if(rCount == rosen) {
                    rosen++;
                }
                gCount++;
            }
        }
        if(isPossible) {
            if(wCount < gCount || wCount < rCount) {
                isPossible = false;
            } else if(gCount != rCount) {
                isPossible = false;
            } else if(gCount != rosen) {
                isPossible = false;
            }
        }
        if(isPossible) {
             return "possible";
        } else
        {
            return "impossible";
        }
    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


5
WWWWWWWWWGR
WWWWGWGRR
WWWWWWWWWWWWWWGRRG
WGRWGR
WWWWWWWWWWWWWWWWWGGWGWGGWGWGGGWGG


 
";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        public static int[] GetInt(char delimiter = ' ', bool trim = false)
        {
            string inptStr = ReadLine();
            if (trim)
            {
                inptStr = inptStr.Trim();
            }
            string[] inpt = inptStr.Split(delimiter);
            int[] ret = new int[inpt.Length];
            for (int i = 0; i < inpt.Length; i++)
            {
                ret[i] = int.Parse(inpt[i]);
            }
            return ret;
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0