Logo
(追記) (追記ここまで)

25875번 - World Cup Fever 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB174426.667%

문제

The 2018 World Cup was held recently in Russia. Some great soccer countries (e.g., Italy, Netherlands, Chile, USA) did not qualify for this World Cup. These countries have found out that they needed more effective passing.

Given the player positions for two teams, determine the minimum number of passes needed to get the ball from one player to another player. For the purposes of this problem, players do not change position, i.e., they do not move.

Player P1 can pass the ball directly to P2 if they are on the same team and no other player is in between the two players.

Let’s assume:

  • P1 and P2 are on the same team
  • P1, P2, P3 form a line with P3 between P1 and P2
  • There are no other players on the line formed by P1, P2, P3

Then,

  • If P3 is on the other team, P1 cannot pass the ball directly to P2.
  • If P3 is on the same team, P1 can pass the ball to P3 to pass it to P2.

입력

The first input line contains an integer, n (2 ≤ n ≤ 11), indicating the number of players on each team. The second input line contains 2n integers, providing the (x,y) coordinates for the n players on Team 1; the first integer on this input line is the x coordinate for Player 1, the second integer is the y coordinate for Player 1, the third integer is the x coordinate for Player 2, etc. The third input line provides (in a similar fashion) the (x,y) coordinates for the n players on Team 2. Assume that all coordinates are integers between 1 and 999 (inclusive) and that all players are on distinct locations, i.e., no two players occupy the same spot (point).

Assume Player 1 on Team 1 has the ball and wants to pass the ball to Player n on Team 1. Assume that any player can pass the ball any distance.

출력

The output consists of a single integer, indicating the minimum number of passes needed to get the ball from Player 1 on Team 1 to Player n on Team 1. If it is not possible to get the ball from Player 1 to Player n, print -1.

제한

예제 입력 1

3
10 15 13 17 10 19
10 17 16 17 13 19

예제 출력 1

2

예제 입력 2

5
1 1 3 1 5 1 7 1 9 1
2 1 4 1 6 1 8 1 10 1

예제 출력 2

-1

예제 입력 3

3
1 1 5 5 2 2
10 10 50 50 20 20

예제 출력 3

1

힌트

출처

University > University of Central Florida > 2018 Local Programming Contest 7번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /