結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2016-05-03 17:09:32 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,290 bytes |
コンパイル時間 | 1,301 ms |
コンパイル使用メモリ | 109,824 KB |
実行使用メモリ | 20,312 KB |
最終ジャッジ日時 | 2024-10-13 14:01:35 |
合計ジャッジ時間 | 4,358 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 30 |
コンパイルメッセージ
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.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int yukyuCount = int.Parse(Reader.ReadLine()); StringBuilder sb = new StringBuilder(); sb.Append(Reader.ReadLine()); sb.Append(Reader.ReadLine()); this.input = sb.ToString(); List<string> kumiawase = this.GetKumiawase(0, yukyuCount); int ans = 0; kumiawase.ForEach((a)=>{ string[] tmp = a.Split('x'); ans = Math.Max(ans, tmp.Max(b=>b.Length)); }); Console.WriteLine(ans); } string input = string.Empty; private Dictionary<int, Dictionary<int, List<String>>> dic = new Dictionary<int, Dictionary<int, List<String>>>(); private List<string> GetKumiawase(int idx, int remainYukyu) { if(!dic.ContainsKey(idx)) { dic.Add(idx, new Dictionary<int, List<string>>()); } if(dic[idx].ContainsKey(remainYukyu)) { return dic[idx][remainYukyu]; } List<string> ans = new List<string>(); if(idx == input.Length - 1) { if(remainYukyu == 0) { ans.Add(this.input[idx].ToString()); } else { if(input[idx] == 'o') { ans.Add("o".PadLeft(remainYukyu + 1, 'o')); } else { ans.Add("o".PadLeft(remainYukyu, 'o')); } } } else { if(this.input[idx] == 'o') { List<string> tmp = this.GetKumiawase(idx+1, remainYukyu); tmp.ForEach(a=>ans.Add("o" + a)); } else { List <string> tmp = this.GetKumiawase(idx+1, remainYukyu); tmp.ForEach(a=>ans.Add("x" + a)); if(remainYukyu > 0) { tmp = this.GetKumiawase(idx+1, remainYukyu - 1); tmp.ForEach(a=>ans.Add("o" + a)); } } } this.dic[idx].Add(remainYukyu, ans); return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 1 oxxxxxo xoxxxxo "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }