結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 14番14番
提出日時 2016-05-03 17:09:32
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,290 bytes
コンパイル時間 1,345 ms
コンパイル使用メモリ 117,048 KB
実行使用メモリ 29,516 KB
最終ジャッジ日時 2024-04-21 15:13:13
合計ジャッジ時間 3,732 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 29 ms
26,976 KB
testcase_05 AC 29 ms
25,268 KB
testcase_06 AC 28 ms
24,816 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 27 ms
25,076 KB
testcase_30 AC 29 ms
25,060 KB
testcase_31 AC 28 ms
27,384 KB
testcase_32 AC 28 ms
26,952 KB
testcase_33 AC 27 ms
27,080 KB
testcase_34 AC 28 ms
25,044 KB
testcase_35 AC 29 ms
25,028 KB
testcase_36 AC 29 ms
25,076 KB
testcase_37 AC 30 ms
25,388 KB
testcase_38 AC 29 ms
26,956 KB
testcase_39 AC 28 ms
27,200 KB
testcase_40 AC 27 ms
24,696 KB
testcase_41 WA -
testcase_42 AC 27 ms
22,964 KB
testcase_43 AC 30 ms
24,948 KB
testcase_44 AC 27 ms
25,092 KB
testcase_45 AC 27 ms
25,296 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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();
    }
}
0