結果

問題 No.345 最小チワワ問題
ユーザー MoonOnRainMoonOnRain
提出日時 2018-07-08 23:22:38
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,307 bytes
コンパイル時間 3,048 ms
コンパイル使用メモリ 108,444 KB
実行使用メモリ 27,984 KB
最終ジャッジ日時 2023-09-22 08:18:32
合計ジャッジ時間 6,930 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
24,032 KB
testcase_01 AC 92 ms
25,816 KB
testcase_02 AC 93 ms
25,964 KB
testcase_03 AC 91 ms
23,716 KB
testcase_04 AC 92 ms
26,216 KB
testcase_05 WA -
testcase_06 AC 95 ms
25,960 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 92 ms
23,936 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 92 ms
23,988 KB
testcase_15 AC 93 ms
24,020 KB
testcase_16 AC 91 ms
26,164 KB
testcase_17 AC 92 ms
24,036 KB
testcase_18 WA -
testcase_19 AC 92 ms
25,916 KB
testcase_20 AC 91 ms
23,880 KB
testcase_21 WA -
testcase_22 AC 91 ms
23,964 KB
testcase_23 AC 92 ms
24,052 KB
testcase_24 AC 92 ms
24,036 KB
testcase_25 AC 92 ms
23,928 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 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;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        private static Regex _regex = new Regex("c.*?w.*?w");

        static void Main(string[] args)
        {
            var target = Console.ReadLine();
            var r = _regex.Matches(target);

            if (r == null)
            {
                Console.WriteLine("-1");
                return;
            }
            var i = 101;
            foreach (Match c in r)
            {
                if (i > c.Length) i = c.MatcheEx(_regex).Value.Length;
            }
            Console.WriteLine(i);

            Console.ReadKey();
        }
    }

    public static class MatchEX
    {
        public static Match MatcheEx(this Match match, Regex regex)
        {
            var target = match.Value.Substring(1);
            var search = regex.Matches(target);

            if(search.Count == 0)
            {
                return match;
            }
            else if (search.Count == 1)
            {
                return search[0].MatcheEx(regex);
            }
            else
            {
                throw new Exception("too match");
            }
        }
    }
}
0