結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー threecoursethreecourse
提出日時 2018-05-05 10:36:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 3,176 bytes
コンパイル時間 3,122 ms
コンパイル使用メモリ 106,544 KB
実行使用メモリ 24,004 KB
最終ジャッジ日時 2023-09-10 10:06:10
合計ジャッジ時間 4,304 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
21,956 KB
testcase_01 AC 64 ms
21,860 KB
testcase_02 AC 64 ms
21,880 KB
testcase_03 AC 65 ms
21,804 KB
testcase_04 AC 65 ms
24,004 KB
testcase_05 AC 64 ms
21,940 KB
testcase_06 AC 65 ms
21,860 KB
testcase_07 AC 66 ms
22,012 KB
testcase_08 AC 65 ms
21,948 KB
testcase_09 AC 65 ms
22,040 KB
testcase_10 AC 65 ms
23,916 KB
testcase_11 AC 65 ms
21,920 KB
testcase_12 AC 64 ms
23,908 KB
testcase_13 AC 63 ms
22,012 KB
testcase_14 AC 64 ms
21,884 KB
testcase_15 AC 65 ms
23,956 KB
testcase_16 AC 62 ms
19,816 KB
testcase_17 AC 63 ms
21,860 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;
using System.Web;

namespace Competitive
{

    internal class Solution
    {
        public int N, XLB, XRB;
        public int[] XL, YU, XR, YD;
        public bool[] H;
        public bool[] USED;
        public Data[] D;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                XLB = line[1];
                XRB = line[2];
            }

            XL = new int[N];
            YU = new int[N];
            XR = new int[N];
            YD = new int[N];
            H = new bool[N];

            for (int i = 0; i < N; i++)
            {
                var line = Input.ReadIntArray();
                XL[i] = line[0];
                YU[i] = line[1];
                XR[i] = line[2];
                YD[i] = line[3];
            }

            D = new Data[N];
            for (int i = 0; i < N; i++)
            {
                D[i] = new Data {NO = i, XL = XL[i], YU = YU[i], XR = XR[i], YD = YD[i]};
            }
            Array.Sort(D);

            int W = 1280;
            USED = new bool[W + 1];

            for (int i = 0; i < N; i++)
            {
                var d = D[i];
                var hit = false;

                int cs = Math.Max(d.XL, XLB);
                int cl = Math.Min(d.XR, XRB);
                for (int c = cs; c <= cl; c++)
                {
                    if (!USED[c])
                    {
                        hit = true;
                        USED[c] = true;
                    }
                }

                if (hit) H[d.NO] = true;
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(H[i] ? 1 : 0);
            }

        }
    }

    // libs ----------
    class Data : IComparable<Data>, IComparable
    {
        public int NO, XL, YU, XR, YD;

        public int CompareTo(Data other)
        {
            // 下が最初、左が最初
            int result = (-YD).CompareTo(-other.YD);
            if (result == 0)
                result = XL.CompareTo(other.XL);
            return result;
        }

      
        public int CompareTo(object obj)
        {
            if (obj == null) return 1;
            if (GetType() != obj.GetType()) throw new ArgumentException();
            return CompareTo((Data)obj);
        }
       
    }


    // common ----------

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}
0