結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,936 KB
testcase_01 AC 63 ms
21,936 KB
testcase_02 AC 63 ms
21,960 KB
testcase_03 AC 64 ms
23,956 KB
testcase_04 AC 63 ms
19,920 KB
testcase_05 AC 63 ms
22,076 KB
testcase_06 AC 63 ms
21,852 KB
testcase_07 AC 63 ms
21,852 KB
testcase_08 AC 64 ms
21,940 KB
testcase_09 AC 63 ms
19,744 KB
testcase_10 AC 64 ms
23,996 KB
testcase_11 AC 64 ms
23,944 KB
testcase_12 AC 64 ms
21,908 KB
testcase_13 AC 66 ms
24,092 KB
testcase_14 AC 64 ms
21,832 KB
testcase_15 AC 67 ms
21,872 KB
testcase_16 AC 63 ms
21,880 KB
testcase_17 AC 65 ms
23,836 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 bool[] USED;
        public Data[] D;

        public void Run()
        {
            int W = 1280;
            USED = new bool[W + 1];

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

            D = new Data[N];
            for (int i = 0; i < N; i++)
            {
                var line = Input.ReadIntArray();
                int XL = line[0];
                int YU = line[1];
                int XR= line[2];
                int YD = line[3];
                D[i] = new Data { NO = i, XL = XL, YU = YU, XR = XR, YD = YD, HIT=false };
            }

            // 下から順に並べ替える
            Array.Sort(D);

            // 下から順に判定
            for (int ii = 0; ii < N; ii++)
            {
                var d = D[ii];
                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) d.HIT = true;
            }

            // 元の順序に戻す
            Array.Sort(D, (d1, d2) => d1.NO.CompareTo(d2.NO));

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

        }
    }

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

        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