포럼
문제 ICPC00177

H. Hole in One

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
설명

Janine recently went to her local game store and bought "Hole in One", a new mini-golf game for her computer. As indicated by the name, the objective of the game is to shoot a ball into a hole using just one shot. The game also borrows elements from brick breaker style games: in the playing field, several walls are placed that will be destroyed upon being hit by the ball. The score of a successful shot depends on the number of destroyed walls, so Janine wonders: what is the maximum number of walls that can be hit while performing a "Hole in One"?

For the purposes of this problem you can think of the playing field as a cartesian plane with the initial position of the ball at the origin. The walls are non-intersecting axis-parallel line segments in this plane (i.e., parallel to either the \(x\) axis or the \(y\) axis). The diameter of the ball is negligible so it is represented as a single point.

Whenever the ball hits a wall, two things happen:
- The direction of the ball changes in the usual way: the angle of incidence equals the angle of reflection.
- The wall that the ball touched is destroyed. Following common video game logic, no rubble of the wall remains; it will be as though it vanished.

The behaviour of the ball is also affected by the power of the shot. In particular, an optimal shot may need to first roll over the hole, then hit some more walls, and only later drop into the hole.

제약
입력 형식

The input consists of:
- one line with one integer \(n\) (\(0 \le n \le 8\)), the number of walls;
- one line with two integers \(x\) and \(y\), the coordinates of the hole;
- \(n\) lines each with four integers \(x_1\), \(y_1\), \(x_2\), and \(y_2\) (either \(x_1 = x_2\), or \(y_1 = y_2\), but not both), representing a wall with end points \((x_1, y_1)\) and \((x_2, y_2)\).

The hole is not at the origin and not on a wall. The walls do not touch or intersect each other. No wall lies completely on the \(x\) axis or the \(y\) axis. All coordinates in the input are integers with absolute value at most \(1\,000\).

출력 형식

If there is no way to shoot the ball such that it reaches the hole, print "impossible". Otherwise, print the maximum number of walls that can be destroyed in a single "Hole in One" shot.

예제 1
입력
3
4 2
1 1 1 2
2 1 2 2
3 1 3 2
출력
2
예제 2
입력
1
2 0
1 -1 1 1
출력
impossible
예제 3
입력
2
-2 4
2 4 2 2
0 6 -2 6
출력
2
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2015

평가 및 의견

H. Hole in One

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

H. Hole in One

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8