結果

問題 No.274 The Wall
ユーザー nokonokonokonoko
提出日時 2015-10-07 21:51:12
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 4,086 bytes
コンパイル時間 2,099 ms
コンパイル使用メモリ 108,948 KB
実行使用メモリ 24,348 KB
最終ジャッジ日時 2023-09-27 07:51:34
合計ジャッジ時間 5,017 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 58 ms
19,996 KB
testcase_02 AC 60 ms
21,980 KB
testcase_03 AC 60 ms
19,960 KB
testcase_04 AC 57 ms
23,936 KB
testcase_05 AC 59 ms
23,924 KB
testcase_06 AC 60 ms
21,896 KB
testcase_07 AC 59 ms
24,000 KB
testcase_08 AC 60 ms
21,988 KB
testcase_09 AC 60 ms
22,132 KB
testcase_10 AC 59 ms
22,120 KB
testcase_11 AC 63 ms
22,104 KB
testcase_12 AC 64 ms
24,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 61 ms
22,180 KB
testcase_17 AC 63 ms
20,128 KB
testcase_18 AC 62 ms
22,244 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 79 ms
20,052 KB
testcase_23 AC 72 ms
22,140 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static int[][] wall;
    static int n;
    static int m;
    static Dictionary<int, bool> check = new Dictionary<int, bool>();
    static int[] rotate(int[] source)
    {
        return source.Reverse().ToArray();
    }
    static bool wallcheck(int now)
    {
        bool ret = false;
        if (now == n - 1)
        {
            ret = true;
        }
        else
        {
            bool nowcheck = true;
            for (int i = wall[now][0]; i <= wall[now][1]; i++)
            {
                if (check[i] == true)
                {
                    nowcheck = false;
                    break;
                }
            }
            if (nowcheck == true)
            {
                for (int i = wall[now][0]; i <= wall[now][1]; i++)
                {
                    check[i] = true;
                }
                ret = wallcheck(now + 1);
                if (ret == false)
                {
                    for (int i = wall[now][0]; i <= wall[now][1]; i++)
                    {
                        check[i] = false;
                    }
                }
            }
            if (ret == false)
            {
                wall[now][0] = m - wall[now][1];
                wall[now][1] = m - wall[now][0];
                nowcheck = true;
                for (int i = wall[now][0]; i <= wall[now][1]; i++)
                {
                    if (check[i] == true)
                    {
                        nowcheck = false;
                        break;
                    }
                }
                if (nowcheck == true)
                {
                    for (int i = wall[now][0]; i <= wall[now][1]; i++)
                    {
                        check[i] = true;
                    }
                    ret = wallcheck(now + 1);
                    if (ret == false)
                    {
                        for (int i = wall[now][0]; i <= wall[now][1]; i++)
                        {
                            check[i] = false;
                        }
                    }
                }
                wall[now][0] = m - wall[now][1];
                wall[now][1] = m - wall[now][0];
            }
        }
        return ret;
    }
    static void Main(string[] args)
    {
        int[] buf = io.r<int>(' ');
        n = buf[0];
        m = buf[1];
        wall = io.r<int>(n, ' ');
        for (int i = 0; i < m; i++)
        {
            check[i] = false;
        }
        bool ret = wallcheck(0);
        string output = "NO";
        if (ret == true)
        {
            output = "YES";
        }
        io.w(output);
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Clear(); }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}
0