結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
No
|
| 提出日時 | 2016-06-08 20:58:51 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,269 bytes |
| コンパイル時間 | 1,439 ms |
| コンパイル使用メモリ | 103,040 KB |
| 実行使用メモリ | 17,536 KB |
| 最終ジャッジ日時 | 2024-10-09 03:22:22 |
| 合計ジャッジ時間 | 3,213 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 16 |
コンパイルメッセージ
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 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);
}
}
}
No