Problem H Binus
Problem H Binus
Help Lili find out whether the two knights (the white and the black one) can meet to-
gether or not.
Format Input
Input consists of 1 integer T indicating number of testcase and followed by 3T row after.
For each test case, the first line contains N , number of step limitation in this game. The
second line contains the coordinate (in chessboard) x1 , y1 , location of the ”black” knight.
The third line contains the coordinate (in chessboard) x2 , y2 , location of the ”white”
knight. Coordinates will be expressed in letter and number form (e.g. A5, A2, C1).
Format Output
Output should be expressed in format ”Case #X: Y” - X is number of testcase and Y is
the answer ”YES” if those two knights can meet together and ”NO” if they can not meet
together (without quotes).
c School of Computer Science - BINUS, 2019. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
For those who violated this disclaimer, academic sanctioned can be enforced.
COMP6047 – Algorithm and Programming
Constraints
• 1 ≤ T, N ≤ 10
• A ≤ x1 , x2 ≤ H
• 1 ≤ y1 , y2 ≤ 8
Explanation
The possible way for them to meet each other described on the figure above. Steps for
the ”black” knight is colored yellow and for the ”white” knight is colored red. Finally,
they meet together in a purple area.
Note
For this problem, there are many possibilities those knights can meet at various points.
So as long as they can meet together, the output will be ”YES”, even though there is
only 1 valid point.
c School of Computer Science - BINUS, 2019. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
For those who violated this disclaimer, academic sanctioned can be enforced.
COMP6047 – Algorithm and Programming
Bantulah Lili dalam mencari tahu apakah kedua kuda tersebut dapat bertemu atau tidak.
Format Input
Input terdiri dari 1 buah angka bulat T yang menyatakan jumlah testcase dan diikuti
oleh 3T baris. Pada tiap kasus, baris pertama terdapat N , batas jalan dari setiap bidak.
Baris kedua berisi koordinat x1 , y1 , lokasi dari kuda hitam. Baris ketiga berisi koordinat
x2 , y2 , lokasi dari kuda putih. Koordinat akan dinyatakan dalam huruf dan angka (contoh
: A5, A2, C1).
Format Output
Output yang dikeluarkan dalam format ”Case #X: Y” - X merupakan nomor testcase dan
Y merupakan jawaban ”YES” apabila kedua kuda tersebut dapat bertemu, dan ”NO”
apabila tidak mungkin kedua tersebut bertemu (jawaban tanpa tanda petik).
c School of Computer Science - BINUS, 2019. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
For those who violated this disclaimer, academic sanctioned can be enforced.
COMP6047 – Algorithm and Programming
Constraints
• 1 ≤ T, N ≤ 10
• A ≤ x1 , x2 ≤ H
• 1 ≤ y1 , y2 ≤ 8
Explanation
Langkah yang dapat ditempuh kedua kuda di atas adalah seperti pada gambar. Kuda
hitam menempuh jalan kuning, kuda putih menempuh jalan yang merah, dan mereka
bertemu di kotak yang berwarna Ungu.
Note
Pada soal ini, ada berbagai kemungkinan kuda dapat bertemu di berbagai titik dan
selama mereka dapat bertemu, hasil outputnya adalah ”YES”, meskipun hanya ada 1
titik yang memenuhi.
c School of Computer Science - BINUS, 2019. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
For those who violated this disclaimer, academic sanctioned can be enforced.