結果

問題 No.38 赤青白ブロック
ユーザー mbanmban
提出日時 2017-07-26 05:00:54
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 502 ms / 5,000 ms
コード長 1,493 bytes
コンパイル時間 3,258 ms
コンパイル使用メモリ 104,532 KB
実行使用メモリ 26,972 KB
最終ジャッジ日時 2023-08-25 01:24:07
合計ジャッジ時間 12,110 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 325 ms
25,004 KB
testcase_01 AC 307 ms
24,832 KB
testcase_02 AC 240 ms
25,020 KB
testcase_03 AC 408 ms
24,924 KB
testcase_04 AC 496 ms
26,952 KB
testcase_05 AC 363 ms
26,916 KB
testcase_06 AC 209 ms
24,740 KB
testcase_07 AC 227 ms
24,796 KB
testcase_08 AC 281 ms
25,020 KB
testcase_09 AC 229 ms
26,868 KB
testcase_10 AC 358 ms
26,860 KB
testcase_11 AC 352 ms
26,876 KB
testcase_12 AC 390 ms
24,956 KB
testcase_13 AC 502 ms
24,920 KB
testcase_14 AC 327 ms
26,876 KB
testcase_15 AC 297 ms
26,940 KB
testcase_16 AC 229 ms
26,940 KB
testcase_17 AC 286 ms
24,908 KB
testcase_18 AC 316 ms
26,920 KB
testcase_19 AC 322 ms
26,812 KB
testcase_20 AC 333 ms
26,864 KB
testcase_21 AC 240 ms
24,956 KB
testcase_22 AC 310 ms
26,960 KB
testcase_23 AC 462 ms
25,016 KB
testcase_24 AC 318 ms
26,972 KB
testcase_25 AC 307 ms
26,868 KB
testcase_26 AC 265 ms
24,928 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int Kr, Kb;
    private string S;
    private int ans = 0;
    private const int Length = 30;
    private bool[] Use = new bool[Length];

    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        Kr = int.Parse(line[0]);
        Kb = int.Parse(line[1]);
        S = Console.ReadLine();
    }

    private void DFS(int n, string s)
    {
        if (n == Length)
        {
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'R' && i - Kr >= 0)
                {
                    if(s[i] == s[i - Kr])
                    {
                        return;
                    }
                }
                else if (s[i] == 'B' && i - Kb >= 0)
                {
                    if(s[i] == s[i - Kb])
                    {
                        return;
                    }
                }
            }
            ans = Math.Max(ans, s.Length);
            return;
        }
        if (S[n] != 'W')
        {
            DFS(n + 1, s);
        }
        DFS(n + 1, s + S[n]);
    }

    public void Solve()
    {
        Scan();
        DFS(0, "");
        Console.WriteLine(ans);
    }
}
0