結果

問題 No.154 市バス
ユーザー mbanmban
提出日時 2016-12-25 10:30:35
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 103,808 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2024-04-21 10:04:03
合計ジャッジ時間 1,746 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
21,760 KB
testcase_01 AC 43 ms
21,632 KB
testcase_02 AC 44 ms
21,504 KB
testcase_03 AC 40 ms
21,760 KB
testcase_04 AC 43 ms
21,504 KB
testcase_05 AC 21 ms
17,536 KB
testcase_06 AC 21 ms
17,408 KB
testcase_07 AC 37 ms
21,376 KB
testcase_08 AC 21 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static int N = int.Parse(Console.ReadLine());
    static void Main()
    {
        for (int i = 0; i < N; i++)
        {
            string S = Console.ReadLine();
            Console.WriteLine(Hantei(S));
        }
    }
    static string Hantei(string s)
    {
        int rcnt = 0;
        int wcnt = 0;
        int gcnt = 0;
        char last = ' ';
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'W') wcnt++;
            if (s[i] == 'G') gcnt++;
            if (s[i] == 'R') rcnt++;
            else last = s[i];
            if (!(wcnt>=gcnt&&gcnt>=rcnt)) return "impossible";
        }
        if (gcnt == rcnt && last == 'G') return "possible";
        else return "impossible";
    }
}


0