結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
tasuku
|
| 提出日時 | 2016-02-27 07:54:46 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 1,144 bytes |
| コンパイル時間 | 935 ms |
| コンパイル使用メモリ | 105,088 KB |
| 実行使用メモリ | 17,792 KB |
| 最終ジャッジ日時 | 2024-09-25 11:28:41 |
| 合計ジャッジ時間 | 2,572 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace yukicoder345
{
class Program
{
static readonly char[] CHIWAWA_WORD = new char[] { 'c', 'w', 'w' };
static int GetChiwawaLength(string str, int sLen)
{
int ret = -1;
int cnt = 0;
for (int i = sLen; i < str.Length; i++)
{
if (CHIWAWA_WORD[cnt] == str[i])
{
cnt++;
if (cnt == CHIWAWA_WORD.Length)
{
ret = (i - sLen) + 1;
break;
}
}
}
return ret;
}
static void Main(string[] args)
{
string s = Console.ReadLine();
int ans = GetChiwawaLength(s, 0);
for (int i = 1; i < s.Length; i++)
{
int tmp = GetChiwawaLength(s, i);
if ((tmp != -1) && (ans > tmp)) ans = tmp;
}
Console.WriteLine(ans);
}
}
}
tasuku