結果

問題 No.345 最小チワワ問題
ユーザー YoshiRyuYoshiRyu
提出日時 2017-04-13 11:04:37
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 2,381 bytes
コンパイル時間 1,364 ms
コンパイル使用メモリ 112,636 KB
実行使用メモリ 25,080 KB
最終ジャッジ日時 2023-10-26 04:07:51
合計ジャッジ時間 3,391 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
25,076 KB
testcase_01 AC 28 ms
25,064 KB
testcase_02 AC 28 ms
25,076 KB
testcase_03 AC 27 ms
25,064 KB
testcase_04 AC 27 ms
25,076 KB
testcase_05 AC 27 ms
25,076 KB
testcase_06 AC 28 ms
25,076 KB
testcase_07 AC 28 ms
25,080 KB
testcase_08 AC 27 ms
25,068 KB
testcase_09 AC 28 ms
25,068 KB
testcase_10 AC 28 ms
25,076 KB
testcase_11 AC 29 ms
25,068 KB
testcase_12 AC 28 ms
25,068 KB
testcase_13 AC 28 ms
25,068 KB
testcase_14 AC 28 ms
25,068 KB
testcase_15 AC 27 ms
25,076 KB
testcase_16 AC 28 ms
25,064 KB
testcase_17 AC 27 ms
25,076 KB
testcase_18 AC 28 ms
25,064 KB
testcase_19 AC 27 ms
25,076 KB
testcase_20 AC 27 ms
25,076 KB
testcase_21 AC 28 ms
25,080 KB
testcase_22 AC 28 ms
25,064 KB
testcase_23 AC 27 ms
25,076 KB
testcase_24 AC 28 ms
25,064 KB
testcase_25 AC 27 ms
25,064 KB
testcase_26 AC 26 ms
25,076 KB
testcase_27 AC 27 ms
25,064 KB
testcase_28 AC 28 ms
25,068 KB
testcase_29 AC 27 ms
25,064 KB
testcase_30 AC 29 ms
25,064 KB
testcase_31 AC 29 ms
25,080 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.Generic;
using System.IO;
using System.Linq;

public class YukiCoder
{
    public static void Solve()
    {
	    var S = MyConsole.String();
	    
	    var fnc = new Func<int>( () => {

	        int cIdx = -1;
	        int wIdx = 0;
	        int min = 101;

	        while (true)
	        {
	            cIdx = S.IndexOf( 'c', cIdx + 1 ); if (cIdx < 0) break;
	            wIdx = S.IndexOf( 'w', cIdx + 1 ); if (wIdx < 0) break;
	            wIdx = S.IndexOf( 'w', wIdx + 1 ); if (wIdx < 0) break;

	            min = Math.Min( min, wIdx - cIdx + 1 );
	        }

	        return min == 101 ? -1 : min;
	    } );

	    MyConsole.wLine( fnc().ToString() );
    }

    public static void Main()
    {
        MyConsole.Read(); Solve(); MyConsole.Finish();
    }
}

public static class MyConsole
{
    private static List<string> ReadedLine = new List<string>();
    private static char[] buf = new char[1024];
    private static int i;

    public static void Read()
    {
        string sr = Console.In.ReadToEnd();

        ReadedLine = sr.Split( new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries ).ToList();

        InputRowCnt = ReadedLine.Count;

        Console.SetOut( new StreamWriter( Console.OpenStandardOutput() ) { AutoFlush = false } );
    }

    public static int InputRowCnt = 0;

    public static string String() { return ( i + 1 > ReadedLine.Count ) ? "" : ReadedLine[i++]; }
    public static string[] StringSplit() { return ReadedLine[i++].Split( new[] { ' ' } ); }

    public static int Int() { return int.Parse( ReadedLine[i++] ); }
    public static int[] IntSplit()
    {
        string[] strs = StringSplit();
        int[] ret = new int[strs.Length];
        for (int i = 0 ; i < strs.Length ; i++)
        {
            ret[i] = int.Parse( strs[i] );
        }

        return ret;
    }
    public static long Long() { return long.Parse( ReadedLine[i++] ); }
    public static double Double() { return double.Parse( ReadedLine[i++] ); }

    public static void Write( string output = null )
    {
        Console.Write( output );
    }

    public static void wLine( string output = null )
    {
        Console.WriteLine( output );
    }

    public static void Finish()
    {
        Console.Out.Flush();
    }
}
0