結果

問題 No.274 The Wall
ユーザー 明智重蔵明智重蔵
提出日時 2015-08-31 20:21:45
言語 C#(csc)
(csc 3.9.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,811 bytes
コンパイル時間 2,450 ms
コンパイル使用メモリ 104,912 KB
実行使用メモリ 24,004 KB
最終ジャッジ日時 2023-09-10 19:47:01
合計ジャッジ時間 5,227 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 63 ms
21,808 KB
testcase_02 WA -
testcase_03 AC 64 ms
21,804 KB
testcase_04 AC 62 ms
21,776 KB
testcase_05 AC 62 ms
19,876 KB
testcase_06 AC 62 ms
21,892 KB
testcase_07 AC 63 ms
21,864 KB
testcase_08 AC 62 ms
21,888 KB
testcase_09 AC 62 ms
19,728 KB
testcase_10 AC 62 ms
21,836 KB
testcase_11 AC 71 ms
19,768 KB
testcase_12 AC 65 ms
21,940 KB
testcase_13 AC 64 ms
21,880 KB
testcase_14 AC 65 ms
23,956 KB
testcase_15 AC 64 ms
21,868 KB
testcase_16 AC 67 ms
23,856 KB
testcase_17 AC 66 ms
21,872 KB
testcase_18 AC 67 ms
23,904 KB
testcase_19 AC 65 ms
23,980 KB
testcase_20 AC 65 ms
21,804 KB
testcase_21 AC 64 ms
19,884 KB
testcase_22 AC 65 ms
22,052 KB
testcase_23 AC 64 ms
23,852 KB
testcase_24 AC 65 ms
21,924 KB
testcase_25 AC 65 ms
24,004 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.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "Input5";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 6");
            WillReturn.Add("5 5");
            WillReturn.Add("2 3");
            WillReturn.Add("4 4");
            WillReturn.Add("1 1");
            //YES
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 6");
            WillReturn.Add("3 5");
            WillReturn.Add("3 4");
            WillReturn.Add("4 4");
            WillReturn.Add("1 2");
            //NO
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2 4");
            WillReturn.Add("0 1");
            WillReturn.Add("0 1");
            //YES
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("5 10");
            WillReturn.Add("8 8");
            WillReturn.Add("0 0");
            WillReturn.Add("2 4");
            WillReturn.Add("2 3");
            WillReturn.Add("8 8");
            //YES
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct LRDef
    {
        internal int L;
        internal int R;
    }

    static int M;

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = { };

        Action<string> SplitAct = (pStr) =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        M = wkArr[1];

        var LRList = new List<LRDef>();
        for (int I = 1; I <= InputList.Count - 1; I++) {
            SplitAct(InputList[I]);
            LRList.Add(new LRDef() { L = wkArr[0], R = wkArr[1] });
        }
        Console.WriteLine(CanCreateGoodWall(LRList) ? "YES" : "NO");
    }

    //良い壁を作成できるかを返す
    static bool CanCreateGoodWall(List<LRDef> pLRList)
    {
        int[] CntArr = new int[M];

        foreach (LRDef EachLR in pLRList) {
            LRDef KaitenLR = DeriveKaitenLR(EachLR);
            int L, R;
            if (EachLR.L < KaitenLR.L) {
                L = EachLR.L; R = EachLR.R;
            }
            else {
                L = KaitenLR.L; R = KaitenLR.R;
            }

            for (int I = L; I <= R; I++) {
                CntArr[I]++;
            }
        }
        return Array.TrueForAll(CntArr, X => X <= 2);
    }

    //180度回転したLRを返す
    static LRDef DeriveKaitenLR(LRDef pLR)
    {
        int NewL = M - 1 - pLR.R;
        int NewR = M - 1 - pLR.L;
        return new LRDef() { L = NewL, R = NewR };
    }
}
0