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

10695번 - Dalia 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB51436632671.491%

문제

The ICPC community feels like an extended family across the world; one of the things that deepens that feeling is when the contest organizers, judges and coaches bring their families with them to the contest sites, so it is not unusual to find children on the contest sites. In the 2013 ICPC, one of the kids who attended was Mohamed, Dalia El-Hefny’s (member in the fund raising team in the ACPC and a very close friend to Fegla since 1998) young son. While wandering around the IBM Chill Zone he happened to come across people playing chess and asked them to teach him how to play, so one of them gave him an introductory book about chess.

One of the sections in that book discussed the knight piece and it is complex movements. In an attempt to teach the reader, the book had many pages where it states a starting position for a knight on a very large board and states an ending position, and asks the reader to decide if the knight can reach the ending position from the starting position after exactly one move. Since you are a smart programmer, Mohamed has asked you to help him to solve the questions in the book.

입력

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100). Followed by T lines, each test case is a single line containing 5 integers, n, r1, c1, r2, c2. The chess board is of size n * n (2 ≤ n ≤ 109). (r1,c1) is the starting position of the knight and (r2,c2) is the ending position. (1 ≤ r1, c1, r2, c2 ≤ n)

출력

For each test case print a single line containing “Case n:” (without the quotes) where n is the test case number (starting from 1) followed by a space then “YES” (without the quotes) if the knight can reach the ending position after making exactly one move or “NO” (without the quotes) if he can not.

제한

예제 입력 1

2
4 1 2 2 4
5 1 1 3 3

예제 출력 1

Case 1: YES
Case 2: NO

힌트

A knight in position (r,c) (r is the row number, and c is the column number, the rows are numbered from 1 to n from the top to the bottom and the columns are numbered from 1 to n from the left to the right) on a chessboard, can move only to one of 8 possible other positions (if that position is within the chess board): (r-1 , c+2) (r-1 , c-2) , (r+1 , c+2) , (r+1 , c-2) , (r-2 , c+1) , (r-2 , c-1) , (r+2 , c+1) , (r+2 , c-1)

About the IBM Chill Zone “a relaxing, fun way to unwind nightly with old and new friends at the ACMICPC World Finals is to stop by the IBM Chill Zone! A great way to participate in interactive games and interesting conversation with innovative IBMers and attendees from all over the world, the IBM Chill Zone is always a favorite for all.”

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > Tunisian Collegiate Programming Contest > TCPC 2013 G번

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

출처

대학교 대회

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

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