結果

問題 No.154 市バス
コンテスト
ユーザー oreoreoresan
提出日時 2018-09-13 13:28:47
言語 C#(csc)
(csc 3.9.0)
コンパイル:
csc -langversion:latest -unsafe -warn:0 -o+ /r:System.Numerics.dll _filename_ -out:a.exe
実行:
/usr/bin/mono a.exe
結果
WA  
実行時間 -
コード長 1,557 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 746 ms
コンパイル使用メモリ 103,296 KB
実行使用メモリ 31,576 KB
最終ジャッジ日時 2026-03-21 22:17:56
合計ジャッジ時間 10,705 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
raw source code

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

namespace shibasu
{
    class Program
    {
        private static int IsShibusPossible(string arg)
        {
            string local_arg = arg;

            int W_pos = local_arg.IndexOf("W");
            int G_pos = local_arg.IndexOf("G");
            int R_pos = local_arg.IndexOf("R");

            if (G_pos == -1 && R_pos == -1)
            {
                return 1;
            }

            if (W_pos == -1 || G_pos == -1 || R_pos == -1)
            {
                return -1;
            }

            if(W_pos > G_pos || W_pos > R_pos)
            {
                return -1;
            }

            if (G_pos > R_pos)
            {
                return -1;
            }

            local_arg = local_arg.Remove(local_arg.IndexOf("W"), 1);
            local_arg = local_arg.Remove(local_arg.IndexOf("G"), 1);
            local_arg = local_arg.Remove(local_arg.IndexOf("R"), 1);

            return IsShibusPossible(local_arg);
        }
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int num = int.Parse(s);

            for(int i = 0; i < num; i++)
            {
                if (IsShibusPossible(Console.ReadLine()) == 1)
                {
                    Console.WriteLine("possible");
                }
                else
                {
                    Console.WriteLine("impossible");
                }

            }
        }
    }
}
0