結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー AreTrashAreTrash
提出日時 2018-04-27 23:52:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 3,293 bytes
コンパイル時間 2,491 ms
コンパイル使用メモリ 108,132 KB
実行使用メモリ 23,948 KB
最終ジャッジ日時 2023-09-10 07:01:50
合計ジャッジ時間 4,658 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,836 KB
testcase_01 AC 67 ms
23,872 KB
testcase_02 AC 67 ms
23,944 KB
testcase_03 AC 66 ms
23,948 KB
testcase_04 AC 65 ms
21,808 KB
testcase_05 AC 65 ms
21,804 KB
testcase_06 AC 66 ms
21,800 KB
testcase_07 AC 67 ms
23,844 KB
testcase_08 AC 66 ms
21,784 KB
testcase_09 AC 66 ms
22,036 KB
testcase_10 AC 66 ms
23,812 KB
testcase_11 AC 67 ms
21,948 KB
testcase_12 AC 66 ms
21,956 KB
testcase_13 AC 67 ms
21,872 KB
testcase_14 AC 66 ms
21,836 KB
testcase_15 AC 67 ms
21,768 KB
testcase_16 AC 66 ms
19,780 KB
testcase_17 AC 66 ms
21,792 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.IO;
using System.Collections.Generic;
using System.Linq;

namespace No678
{
    public class Program
    {
        struct Enemy
        {
            public int Index { get; }
            public int XL { get; }
            public int YU { get; }
            public int XR { get; }
            public int YD { get; }

            public Enemy(int index, int xl, int yu, int xr, int yd)
            {
                Index = index;
                XL = xl;
                YU = yu;
                XR = xr;
                YD = yd;
            }
        }

        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var xLB = ss.Next(int.Parse);
            var xRB = ss.Next(int.Parse);

            var enemies = new List<Enemy>();
            for (var i = 0; i < N; i++)
            {
                var XL = Math.Max(0, ss.Next(int.Parse));
                var YU = ss.Next(int.Parse);
                var XR = Math.Min(1280, ss.Next(int.Parse));
                var YD = ss.Next(int.Parse);
                enemies.Add(new Enemy(i, XL, YU, XR, YD));
            }

            var beam = new bool[1281];
            for (var i = 0; i < xLB; i++) beam[i] = true;
            for (var i = xRB + 1; i <= 1280; i++) beam[i] = true;

            var ans = new bool[N];
            foreach (var enemy in enemies.OrderByDescending(e => e.YD))
            {
                var check = false;
                for (var i = enemy.XL; i <= enemy.XR; i++)
                {
                    check |= !beam[i];
                    beam[i] = true;
                }
                ans[enemy.Index] = check;
            }

            foreach (var b in ans) sw.WriteLine(b ? 1 : 0);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}
0