結果

問題 No.345 最小チワワ問題
ユーザー NoNo
提出日時 2016-06-08 20:58:51
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,269 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 109,768 KB
実行使用メモリ 25,940 KB
最終ジャッジ日時 2024-04-17 09:55:44
合計ジャッジ時間 2,326 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 22 ms
25,676 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 22 ms
25,428 KB
testcase_08 AC 23 ms
23,516 KB
testcase_09 AC 22 ms
23,776 KB
testcase_10 AC 22 ms
25,800 KB
testcase_11 AC 22 ms
25,816 KB
testcase_12 AC 22 ms
23,732 KB
testcase_13 AC 22 ms
23,476 KB
testcase_14 WA -
testcase_15 AC 21 ms
25,556 KB
testcase_16 AC 22 ms
23,636 KB
testcase_17 AC 22 ms
23,648 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 21 ms
23,776 KB
testcase_21 AC 22 ms
23,516 KB
testcase_22 AC 22 ms
21,304 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 21 ms
23,520 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 21 ms
23,388 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.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yukikoda
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Length < 3)
            {
                Console.WriteLine("-1");
                return;
            }

            int i = 0;
            int min = int.MaxValue;

            while (s.IndexOf('c', i) != -1)
            {
                i = s.IndexOf('c', i) + 1;
                if (i == s.Length - 1) break;

                int wc = 0;

                for (int j = i + 1; j < s.Length - 1; j++)
                {
                    if (s[j] == 'w')
                    {
                        wc++;
                        if (wc == 2)
                        {
                            if (min > j + 2 - i)
                            {
                                min = j + 2 - i;
                                break;
                            }
                        }
                    }
                }


            }

            if (min == int.MaxValue)
            {
                min = -1;
            }
            Console.WriteLine(min);
        }
    }
}
0