結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー fujita
提出日時 2023-05-10 16:01:09
言語 C#
(.NET 10.0.201)
コンパイル:
dotnet_c
実行:
/usr/bin/dotnet_wrap
結果
WA  
実行時間 -
コード長 1,200 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,925 ms
コンパイル使用メモリ 173,204 KB
実行使用メモリ 191,892 KB
最終ジャッジ日時 2026-05-21 05:27:01
合計ジャッジ時間 11,157 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (89 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

using System;
namespace yukicoder
{
    class Program
    {

        static void Main(string[] args)
        {

            var str = Console.ReadLine();
            string[] strings = new string[str.Length];
            int C = 0 , W = 0 ,  Ccnt = 0 , Wcnt = 0 , anscount = 0;


            for (int i = 0; i < str.Length; i++)
            {
                if(str.Substring(i,1) == "c" && Wcnt == 0)
                {        
                    C = 1;
                    Ccnt = i;
                }
                else if (str.Substring(i, 1) == "w" && C == 1)
                {
                    W++;
                    Wcnt = i;
                }
                
                if(C == 1 && W == 2)
                {
                    int sum = Wcnt - Ccnt + 1;
                    anscount = sum;
                    C = 0;
                    Ccnt = 0;
                    W = 0;
                    Wcnt = 0;
                }
                
            }

            if(anscount > 0)
            {
                Console.WriteLine(anscount);
            }
            else if (anscount == 0)
            {
                Console.WriteLine("-1");
            }
        }
    }
}
0