結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
neko_the_shadow
|
| 提出日時 | 2018-06-23 11:32:20 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 970 bytes |
| コンパイル時間 | 4,244 ms |
| コンパイル使用メモリ | 110,776 KB |
| 実行使用メモリ | 26,644 KB |
| 最終ジャッジ日時 | 2024-09-25 12:15:40 |
| 合計ジャッジ時間 | 3,190 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
namespace _345
{
class Program
{
static void Main(string[] args)
{
var s = Console.ReadLine();
var sizes = new List<int>();
for (int x1 = 0, len = s.Length; x1 < len; x1++)
{
if (s[x1] != 'c')
{
continue;
}
var x2 = s.IndexOf('w', x1 + 1);
if (x2 == -1)
{
continue;
}
var x3 = s.IndexOf('w', x2 + 1);
if (x3 == -1)
{
continue;
}
sizes.Add(x3 - x1 + 1);
}
if (sizes.Any())
{
Console.WriteLine(sizes.Min());
}
else
{
Console.WriteLine(-1);
}
}
}
}
neko_the_shadow