結果

問題 No.380 悪の台本
ユーザー bluemeganebluemegane
提出日時 2021-05-12 17:05:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 262 ms / 1,000 ms
コード長 1,436 bytes
コンパイル時間 4,072 ms
コンパイル使用メモリ 109,996 KB
実行使用メモリ 31,176 KB
最終ジャッジ日時 2023-10-24 06:33:04
合計ジャッジ時間 5,751 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
29,052 KB
testcase_01 AC 67 ms
29,140 KB
testcase_02 AC 69 ms
29,132 KB
testcase_03 AC 69 ms
29,136 KB
testcase_04 AC 77 ms
29,152 KB
testcase_05 AC 109 ms
31,176 KB
testcase_06 AC 96 ms
29,140 KB
testcase_07 AC 262 ms
25,368 KB
testcase_08 AC 71 ms
29,888 KB
testcase_09 AC 77 ms
29,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Text.RegularExpressions;
using System.Collections.Generic;
using System;

public class hello
{
    public static HashSet<string> hs;
    public static string ok = "CORRECT (maybe)";
    public static string ng = "WRONG!";
    static void Main()
    {
        var a0 = new string[] { "digi ", "gema ", "piyo ", "rabi " };
        hs = new HashSet<string>();
        foreach (var x in a0) hs.Add(x);
        string L;
        for (; (L = Console.ReadLine()) != null;)
        {
            if (L.Length < 5) { Console.WriteLine(ng); continue; }
            var name = L.Substring(0, 5);
            if (hs.Contains(name)) getAns(name.Substring(0, 4), L.Substring(5));
            else
            {
                var name2 = L.Substring(0, 6);
                if (name2 == "petit ") getAns(name.Substring(0, 5), L.Substring(6));
                else Console.WriteLine(ng);
            }
        }
    }
    static void getAns(string a, string b)
    {
        var t = b.ToLower();
        bool ans;
        if (a == "digi") ans = Regex.IsMatch(t, @"nyo[^a-zA-Z0-9]{0,3}$");
        else if (a == "petit") ans = Regex.IsMatch(t, @"nyu[^a-zA-Z0-9]{0,3}$");
        else if (a == "gema") ans = Regex.IsMatch(t, @"gema[^a-zA-Z0-9]{0,3}$");
        else if (a == "rabi") ans = Regex.IsMatch(t, @"[a-zA-Z0-9]{1,}");
        else ans = Regex.IsMatch(t, @"pyo[^a-zA-Z0-9]{0,3}$");
        Console.WriteLine(ans ? ok : ng);
    }
}
0