시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 182 30 23 25.000%

문제

크기가 무한대인 체스판 위에 두 칸 (x1,y1)와 (x2, y2)가 주어졌을 때, (K,N)-나이트가 (x1, y1)에서 (x2, y2)로 이동할 수 있는지를 구하는 프로그램을 작성하시오.

(K,N)-나이트는 원래 나이트가 움직이는 방식과 비슷하다. (K,N)-나이트는 가로로 K칸, 세로로 N칸 떨어진 곳이나, 가로로 N칸, 세로로 K칸 떨어진 곳으로 한 번에 이동할 수 있다. 체스에서 사용하는 나이트는 (2,1)-나이트나 (1,2)-나이트로 생각할 수 있다.

입력

첫째 줄에 테스트 케이스의 개수 T(1 ≤ T ≤ 20,000)가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, K, N, x1, y1, x2, y2 (0 ≤ K, N ≤ 109, K+N > 0, -109 ≤ x1,y1,x2,y2 ≤ 109) 가 공백으로 구분되어져 있다. 

출력

각 테스트 케이스마다, 주어진 (K,N)-나이트가 (x1, y1)에서 (x2, y2)로 이동할 수 있으면 "TAK", 없으면 "NIE"를 출력한다.

예제 입력 1

3
2 1 0 0 3 3
1 1 1 1 1 2
1 0 2 3 4 6

예제 출력 1

TAK
NIE
TAK
W3sicHJvYmxlbV9pZCI6IjgzMjIiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiIoSyxOKS1cdWIwOThcdWM3NzRcdWQyYjgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1ZDA2Y1x1YWUzMFx1YWMwMCBcdWJiMzRcdWQ1NWNcdWIzMDBcdWM3NzggXHVjY2I0XHVjMmE0XHVkMzEwIFx1YzcwNFx1YzVkMCBcdWI0NTAgXHVjZTc4ICh4MSx5MSlcdWM2NDAgKHgyLCB5MilcdWFjMDAgXHVjOGZjXHVjNWI0XHVjODRjXHVjNzQ0IFx1YjU0YywgKEssTiktXHViMDk4XHVjNzc0XHVkMmI4XHVhYzAwICh4MSwgeTEpXHVjNWQwXHVjMTFjICh4Mi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WNlcy4gSyBhbmQgTiBkZXNjcmliZSB0aGUgcG9zc2libGUgbW92ZXMgb2YgdGhlIGtuaWdodC4gVGhlIGtuaWdodCBzdGFydHMgaXRzIG1vdmVtZW50IGluIHNxdWFyZSAoeDEsIHkxKS4gVyB3b3VsZCBsaWtlIHRvIGNoZWNrIGlmIGl0IGNhbiBnZXQgdG8gc3F1YXJlICh4MiwgeTIpLjxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPkZvciBlYWNoIHRlc3QgY2FzZSBleGFjdGx5IG9uZSBsaW5lIHNob3VsZCBiZSB3cml0dGVuIHRvIHRoZSBzdGFuZGFyZCBvdXRwdXQuIEl0IHNob3VsZCBjb250YWluIGEgd29yZCBUQUsgKG1lYW5pbmcgWUVTKSBvciBOSUUgKG1lYW5pbmcgTk8pIGRlcGVuZGluZyBvbiB3aGV0aGVyIGEgKEssTikta25pZ2h0IHN0YXJ0aW5nIGZyb20gc3F1YXJlICh4MSx5MSkgY2FuIGdldCB0byBzcXVhcmUgKHgyLHkyKS48XC9wPlxyXG5cclxuPHA+Jm5ic3A7PFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsImh0bWxfdGl0bGUiOiIwIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

Contest > Algorithmic Engagements > PA 2009 2-1번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: hhs250