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

6959번 - You Can't Get There From Here 다국어

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

문제

In a primitive video game, a spot bounces around within a rectangular grid. The southwest corner of the grid has coordinates $(0,0)$ and the northeast corner has coordinates $(r,c)$ where 0ドル < r \le 10$ and 0ドル < c \le 10$. The southeast corner has coordinates $(0,c)$ and the northwest corner has coordinates $(r,0)$. The spot always travels on the diagonal; that is, in one of the directions NE, NW, SE, SW. The outer edges of the grid serve as mirrors: after visiting a position on the edge of the grid the spot "bounces" off according to the normal rules of reflection (Snell's Law). For example, if the spot were travelling NE and hit the east edge of the grid, it would change direction to NW. If the spot were to hit the corner of the grid it would change to the opposite direction.

Given a grid size, two points $A$ and $B$ lying on the grid, and an initial direction, you are to determine if the spot moves from $A$ to $B$ and, if so, how far the spot moves (in terms of number of grid positions) before reaching $B$ the first time.

입력

The input consists of an integer $n,ドル followed by $n$ data sets. Each data set begins with a line containing $r$ and $c,ドル followed by two lines containing the coordinates of points $A$ and $B$ respectively, followed by one line containing NE, NW, SE, or SW - the initial direction of travel.

출력

For each case, print a sentence as shown below indicating whether or not $B$ can be reached, and, if it can, how far the spot moves before reaching $B$.

제한

예제 입력 1

2
3 4
0 0
0 4
NE
4 2
3 1
3 2
NW

예제 출력 1

B can be reached from A after 12 move(s).
B cannot be reached from A.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 1999 > CCO 1999 1번

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

출처

대학교 대회

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

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