結果

問題 No.154 市バス
ユーザー mori_chibimori_chibi
提出日時 2017-08-22 14:57:37
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,077 bytes
コンパイル時間 1,297 ms
コンパイル使用メモリ 107,648 KB
実行使用メモリ 23,424 KB
最終ジャッジ日時 2024-04-21 10:20:13
合計ジャッジ時間 3,217 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 796 ms
23,424 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;

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;
            for (int i = 0; i < lines; i++)
            {
                line.Add(Console.ReadLine());
            }
            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 = 0b0001;
            const byte color_g = 0b0010;
            const byte color_w = 0b0100;
            const byte color_rg = 0b0011;
            const byte color_rgw = 0b0111;
            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;
                    }
                    else if (this[i] == color_rgw)
                    {
                        ;
                    }
                    else
                    {
                        return false;
                    }
                }
                return true;
            }
            public bool Inspect()
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if (this[i] != color_rgw)
                    {
                        return false;
                    }
                }
                return true;
            }
        }
    }
}
0