system
October 13, 2018, 3:03pm
#1
Limits: 2s, 512 MB
We all know about the chess game. Chess game is played on 8x8 board. Now, Alice and Bob come to play chess. They go to the chess grandmaster Magnus Carlsen to request him to organize their chess matches. So Magnus Carlsen organizes the match between them. But he sets up the new rules of the chess for the both players.
There are only two types of pieces: Knight and Bishop.
Each player is provided exactly one chess piece, either Bishop or Knight. (Both player can have same pieces.).
This is a companion discussion topic for the original entry at https://toph.co/p/knight-and-bishop
sha212
February 14, 2022, 4:27am
#2
@hjr265 @khatribiru Sorry but can you please provide some more sample sets? I am getting WA in test 2,or any hint/s where is the bug?
T=int(input())
for i in range(0,T):
num=i+1
moveinput=input()
room1=moveinput[1]
alphabet='abcdefgh'
for j in range(len(alphabet)):
if room1 == alphabet[j]:
roomno1=int(j)
numroom1=int(moveinput[2])
if (numroom1+roomno1)%2==0:
roomcolor1='white'
if (numroom1+roomno1)%2!=0:
roomcolor1='black'
room2=moveinput[5]
alphabet='abcdefgh'
for j in range(len(alphabet)):
if room2 == alphabet[j]:
roomno2=int(j)
numroom2=int(moveinput[6])
if (numroom2+roomno2)%2==0:
roomcolor2='white'
if (numroom2+roomno2)%2!=0:
roomcolor2='black'
if moveinput[0]=='B': #differentcolorbishop
if moveinput[4]=='B':
if roomcolor1!=roomcolor2:
print("Case "+str(num)+": Draw")
if roomcolor1==roomcolor2: #samecolorbishop
if abs(roomno1-roomno2)==abs(int(moveinput[2])-int(moveinput[6])):
print("Case "+str(num)+": Alice")
if abs(roomno1-roomno2)!=abs(int(moveinput[2])-int(moveinput[6])):
print("Case "+str(num)+": Draw")
if moveinput[0]=='K': #2knight
if moveinput[4]=='K':
if (roomno2 == roomno1 + 1 or roomno2 == roomno1 - 1) and (int(moveinput[6]) == int(moveinput[2]) - 2 or int(moveinput[6]) == int(moveinput[2]) + 2):
print("Case "+str(num)+": Alice")
elif (roomno2 == roomno1 - 2 or roomno2 == roomno1 + 2) and (int(moveinput[6]) == int(moveinput[2]) - 1 or int(moveinput[6]) == int(moveinput[2]) + 1):
print("Case "+str(num)+": Alice")
else:
print("Case "+str(num)+": Draw")
if moveinput[0]=='B': #knightbishop
if moveinput[4]=='K':
if abs(roomno1-roomno2)==abs(int(moveinput[2])-int(moveinput[6])):
print("Case "+str(num)+": Alice")
if abs(roomno2-roomno1)!=abs(int(moveinput[6])-int(moveinput[2])):
if (roomno1 == roomno2 + 1 or roomno1 == roomno2 - 1) and (int(moveinput[2]) == int(moveinput[6]) - 2 or int(moveinput[2]) == int(moveinput[6]) + 2):
print("Case "+str(num)+": Bob")
elif (roomno1 == roomno2 - 2 or roomno1 == roomno2 + 2) and (int(moveinput[2]) == int(moveinput[6]) - 1 or int(moveinput[2]) == int(moveinput[6]) + 1):
print("Case "+str(num)+": Bob")
else:
print("Case "+str(num)+": Draw")
if moveinput[0]=='K': #knightbishop
if moveinput[4]=='B':
if (roomno2 == roomno1 + 1 or roomno2 == roomno1 - 1) and (int(moveinput[6]) == int(moveinput[2]) - 2 or int(moveinput[6]) == int(moveinput[2]) + 2):
print("Case "+str(num)+": Alice")
elif (roomno2 == roomno1 - 2 or roomno2 == roomno1 + 2) and (int(moveinput[6]) == int(moveinput[2]) - 1 or int(moveinput[6]) == int(moveinput[2]) + 1):
print("Case "+str(num)+": Alice")
else:
if abs(roomno2-roomno1)==abs(int(moveinput[6])-int(moveinput[2])):
print("Case "+str(num)+": Bob")
if abs(roomno1-roomno2)!=abs(int(moveinput[2])-int(moveinput[6])):
print("Case "+str(num)+": Draw")