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

31020번 - Collision Alert 다국어

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

문제

You're almost free. You've successfully fought your way out of the haunted mansion; now the only obstacle remaining is a square field. The field is completely flat, so it should be a breeze to cross it, right? Too bad the field is full of ghosts...

When you start (time = 0 seconds), you and each of the ghosts are located at some set of integer coordinates (the center of the field is (0,0)). No ghost can start at the same position as you or another ghost.

You and the ghosts can only move in straight lines parallel to the sides of the field, and you and the ghosts will not necessarily all be going in the same direction. All ghosts are the same size as you, and neither the ghosts nor you can change direction once started.

The ghosts will start moving at the same time you do, and you and the ghosts will all be moving at the same constant rate (velocity = 1 unit per second).

Ghosts pass through each other, and doing so does not change their speed or direction. Similarly, if a ghost runs into what would have been the field's boundary, they pass beyond it and are no longer within the field's potential collision space.

Given the starting positions and direction for you and each of the ghosts, find the earliest time at which you will collide with a ghost. If you will have no collisions with any ghosts, you are SAFE.

입력

The first line of input contains T (1 ≤ T ≤ 10), indicating the number of times you will try to cross the field.

In each of the following T lines, the first line contains X Y DIR, where (X,Y) is your initial position (-100 ≤ X, Y ≤ 100) and DIR is the direction you will move.

DIR is given as N (north / towards positive Y), S (south / towards negative Y), E (east / towards positive X), or W (west / towards negative X).

The second line contains G (1 ≤ G ≤ 2012), the number of ghosts on the field. G lines follow, each containing X Y DIR, the initial position and the direction of movement for each ghost (following the same constraints for X, Y, and DIR as you).

출력

For each time you try to cross the field, output the earliest time in seconds (rounded to one decimal point) at which you will collide with a ghost. If you will have no collisions with any ghosts, output SAFE.

제한

예제 입력 1

3
-3 2 E
2
-2 3 S
-2 0 N
0 0 E
1
3 0 W
1 1 N
1
1 0 N

예제 출력 1

1.0
1.5
SAFE

힌트

출처

ICPC > Regionals > North America > South Central USA Regional > 2016 South Central USA Regional Programming Contest C번

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

출처

대학교 대회

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

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