結果

問題 No.345 最小チワワ問題
ユーザー mrc1031
提出日時 2016-10-12 11:29:42
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 524 bytes
コンパイル時間 3,121 ms
コンパイル使用メモリ 102,016 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-11-22 02:37:08
合計ジャッジ時間 2,608 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 14 RE * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;

class Program
{
    static void Main(string[] args)
    {
        // No.345 最小チワワ問題

        string S = Console.ReadLine();

        int cIdx = -1, wIdx = -1;

        cIdx = S.IndexOf('c');              // C
        wIdx = S.IndexOf('w', cIdx);        // w(1文字目)
        wIdx = S.IndexOf('w', wIdx + 1);    // w(2文字目)

        if (cIdx == -1 || wIdx == -1)
            Console.WriteLine(-1);
        else
            Console.WriteLine(wIdx - (cIdx - 1));
    }
}
0