結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-24 17:49:02 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,101 bytes |
| 記録 | |
| コンパイル時間 | 922 ms |
| コンパイル使用メモリ | 112,696 KB |
| 実行使用メモリ | 28,568 KB |
| 最終ジャッジ日時 | 2024-09-16 04:39:32 |
| 合計ジャッジ時間 | 2,913 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 1 |
| other | AC * 14 WA * 14 RE * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var input = Console.ReadLine();
var chArr = input.ToCharArray();
int first_c = 0;
int first_w = 0;
int last_w = 0;
int len = 0;
if (chArr.Count(x => x == 'c') >= 1 && chArr.Count(x => x == 'w') >= 2)
{
input = new string(chArr);
first_c = input.IndexOf('c');
first_w = input.IndexOf('w');
last_w = input.LastIndexOf('w');
len = (last_w - first_c) + 1;
input = input.Substring(first_c, len);
first_c = input.IndexOf('c');
first_w = input.IndexOf('w');
for (int i = first_w + 1; i <input.Length; i++)
{
if (input[i] == 'w')
{
last_w = i;
break;
}
}
input = input.Substring(0, last_w + 1);
Console.WriteLine(input.Length);
}
else Console.WriteLine("-1");
}
}