結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2018-09-30 13:55:35 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,173 bytes |
コンパイル時間 | 4,370 ms |
コンパイル使用メモリ | 110,696 KB |
実行使用メモリ | 29,300 KB |
最終ジャッジ日時 | 2024-10-12 09:03:35 |
合計ジャッジ時間 | 3,643 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic; using System.Linq; using System; public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var t = new string('x', n); var t2 = new string('o', n); var s = t + Console.ReadLine().Trim() + Console.ReadLine().Trim() + t; var p = 0; var ans = new List<int>(); while (p <= s.Length - n) { var a = s.IndexOf(t, p); if (p >= 0) { var a2 = s.Substring(0, a) + t2 + s.Substring(a + n); ans.Add(countO(a2)); p++; } else break; } Console.WriteLine(ans.Max()); } public static int countO(string s) { var ans = 0; var count = 0; var cbegin = false; foreach (var x in s) if (x == 'o') { count++; if (cbegin) ans = Math.Max(ans, count); else cbegin = true; } else { count = 0; cbegin = false; } return ans; } }