結果

問題 No.154 市バス
ユーザー mori_chibimori_chibi
提出日時 2017-08-22 17:48:00
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 3,366 bytes
コンパイル時間 906 ms
コンパイル使用メモリ 108,160 KB
実行使用メモリ 23,936 KB
最終ジャッジ日時 2024-04-21 10:20:54
合計ジャッジ時間 4,923 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Text;

namespace Citybus
{
    class Program
    {
        static void Main(string[] args)
        {
            bool possible;
            char[] charary;
            Tube TestTube = new Tube();
            int lines = int.Parse(Console.ReadLine());
            List<string> line = new List<string>();
            Predicate<byte> deleteall = DeleteAll;
            Console.SetIn(new StreamReader(Console.OpenStandardInput(),
                               new System.Text.UTF8Encoding(),
                               false,
                               1024));
            /*Stream inputStream = Console.OpenStandardInput();
            byte[] bytes = new byte[2048];*/
            int outputLength;
            for (int i = 0; i < lines; i++)
            {
                line.Add(Console.ReadLine());
                /*outputLength = inputStream.Read(bytes, 0, 2048);
                line.Add(new string(Encoding.UTF8.GetChars(bytes, 0, outputLength)));*/
            }
            for (int i = 0; i < lines; i++)
            {
                possible = true;
                charary = line[i].ToCharArray();
                for (int j = charary.Length - 1; j > -1 && possible; j--)
                {
                    switch (charary[j])
                    {
                        case 'R': TestTube.AddRed(); break;
                        case 'G': possible = TestTube.AddGreen();  break;
                        case 'W': possible = TestTube.AddWhite(); break;
                    }
                }
                if( possible && TestTube.Inspect() )
                {
                    Console.WriteLine("possible");
                }
                else
                {
                    Console.WriteLine("impossible");
                }
                TestTube.RemoveAll(deleteall);
            }
        }
        private static bool DeleteAll(byte b)
        {
            return true;
        }
        private class Tube : List<byte>
        {
            const byte color_r = 1;
            const byte color_g = 2;
            const byte color_w = 4;
            const byte color_rg = 3;
            const byte color_rgw = 7;
            public void AddRed()
            {
                this.Add(color_r);
            }
            public bool AddGreen()
            {
                for(int i = 0; i < this.Count; i++)
                {
                    if (this[i] == color_r)
                    {
                        this[i] += color_g;
                        return true;
                    }
                };
                return false;
            }
            public bool AddWhite()
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if (this[i] == color_rg)
                    {
                        this[i] += color_w;
                        return true;
                    }
                }
                return true;
            }
            public bool Inspect()
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if (this[i] != color_rgw)
                    {
                        return false;
                    }
                }
                return true;
            }
        }
    }
}
0