시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 136 17 12 25.532%

문제

크기가 무한대인 체스판 위에 두 칸 (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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gYW5kIE4gZGVzY3JpYmUgdGhlIHBvc3NpYmxlIG1vdmVzIG9mIHRoZSBrbmlnaHQuIFRoZSBrbmlnaHQgc3RhcnRzIGl0cyBtb3ZlbWVudCBpbiBzcXVhcmUgKHgxLCB5MSkuIFcgd291bGQgbGlrZSB0byBjaGVjayBpZiBpdCBjYW4gZ2V0IHRvIHNxdWFyZSAoeDIsIHkyKS48XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5Gb3IgZWFjaCB0ZXN0IGNhc2UgZXhhY3RseSBvbmUgbGluZSBzaG91bGQgYmUgd3JpdHRlbiB0byB0aGUgc3RhbmRhcmQgb3V0cHV0LiBJdCBzaG91bGQgY29udGFpbiBhIHdvcmQgVEFLIChtZWFuaW5nIFlFUykgb3IgTklFIChtZWFuaW5nIE5PKSBkZXBlbmRpbmcgb24gd2hldGhlciBhIChLLE4pLWtuaWdodCBzdGFydGluZyBmcm9tIHNxdWFyZSAoeDEseTEpIGNhbiBnZXQgdG8gc3F1YXJlICh4Mix5MikuPFwvcD5cclxuXHJcbjxwPiZuYnNwOzxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

Contest > Algorithmic Engagements > PA 2009 2-1번

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