問題一覧 > 通常問題

No.678 The Special Beam of a 2D Shooting Game

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 134
作問者 : horiesiniti / テスター : はむこ
お気に入りにしたユーザー ProblemId : 1209 / 自分の提出
問題文最終更新日: 2026-10-16 17:06:38
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 189 (順位表) の他の問題:

Problem Statement

You will implement the hit detection of a wide beam for a 2D vertical shooting game that scrolls from bottom to top. In the game, the player's ship can make a request to the mothership, and the mothership will fire a wide beam. Implement the hit detection of the beam.

The beam's hit detection and the enemy data follow the rules below.

  • The width of the beam is the range whose left end is at pixel $xLB$ and which extends rightward to pixel $xRB$ (pixel coordinates counted one pixel at a time from the left edge of the screen toward the right).
  • The height of the beam reaches from far below the bottom of the screen (you may consider it infinite) up to the very top of the screen.
  • The beam covers a rectangular range exactly aligned with the vertical and horizontal directions, that is, the X axis and the Y axis.
  • Since this is a special beam, it naturally does not hit the player's ship.
  • The beam is assumed to be fired from the bottom of the screen upward. When it hits an enemy, the beam in that range stops and does not hit enemies behind it.
  • The beam counts as a hit if it touches even one dot, and counts as a miss if it is off by even one dot.
  • The hitbox of an enemy is also a rectangle exactly aligned with the vertical and horizontal directions, and is never a slanted rectangle.

(This is probably hard to understand from words alone. Refer to the sample inputs, which are explained with figures.)

Input

$N$ $xLB$ $xRB$
$XL_1$ $YU_1$ $XR_1$ $YD_1$
$\dots$
$XL_n$ $YU_n$ $XR_n$ $YD_n$

The screen size is fixed at 1280 pixels wide and 1680 pixels tall. You may assume that all input values are integers and that, except for the number of enemies, they denote pixel coordinates.
The top-left dot of the screen is (1,1) and the bottom-right dot of the screen is (1280,1680).
You may assume that each enemy is always partly or entirely on the screen.
For any two enemies, the dot ranges of their hitboxes never overlap.
If an enemy's left and right, and top and bottom, have the same coordinates, it is treated as an enemy of 1*1 dots.

$0 \le N \le 188$
$ 1 \le xLB < xRB \le 1280$
$-500 \le XL_i \le 1280$
$max(0,XL_i) \le XR_i \le 2000$
$-500 \le YU_i \le 1680$
$max(0,YU_i) \le YD_i \le 2180$

$N$ is the number of enemies. $xLB$ is the left end of the beam and $xRB$ is the right end of the beam. The following $N$ lines give the hitbox of enemy $i$. The top-left of the hitbox of enemy $i$ is ($XL_i$,$YU_i$) and its bottom-right is ($XR_i$,$YD_i$); the enemy is a non-slanted rectangle aligned with the vertical and horizontal directions.

Output

$H_1$
$\dots$
$H_n$

For each enemy, output on one line $H_i$, which is 1 if enemy $i$ is hit by the special beam and 0 otherwise.

Print a newline at the end.

Sample

Sample 1
Input
6 30 200
25 150 50 175
100 150 125 175
150 150 175 175
75 100 160 125
74 50 100 75
130 50 165 75
Output
1
1
1
1
1
0

The light blue area is the effective range of the beam. The enemies are the red rectangles. The left x-coordinate of enemy 4 is 75, and the left x-coordinate of enemy 5 is 74. It looks as if enemy 4 acts as a wall, but since the left X-coordinate of enemy 5 is 74, it is hit by the beam. If the left x-coordinate of enemy 5 were 75, the beam would miss it by a difference of one dot. Enemy 6 is not hit by the beam because enemies 4 and 3 act as walls.

Here is one more example. Suppose a beam with left end 0 and right end 300 hits an enemy with left coordinate 100 and right coordinate 200. Then the beam splits into two parts, 0 to 99 and 201 to 300.

Sample 2
Input
6 30 190
-20 75 50 100
80 120 130 140
166 90 200 120
40 45 165 60
140 10 200 20
35 20 50 30
Output
1
1
1
1
0
0

Enemies 1, 2, 3, and 4 are hit. Enemy 5 is guarded by the exquisite block formed by enemies 3 and 4. If enemies 3 and 4 were off by even one dot, the beam would hit enemy 5.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。