Official
B - Tournament Result Editorial by en_translator
For all pairs \((i,j)\), check if \(A_{i,j}\) and \(A_{j,i}\) correspond appropriately.
Use double loop to implement it. Beware of the cases where \(i=j\). The implementation may be simplified by terminating the program once a contradictory result has been found.
Sample code (Python)
N=int(input())
A=[input()for i in range(N)]
for i in range(N):
for j in range(N):
if i==j:continue
if A[i][j]=="W":
if A[j][i]!="L":
print("incorrect")
exit()
elif A[i][j]=="D":
if A[j][i]!="D":
print("incorrect")
exit()
elif A[i][j]=="L":
if A[j][i]!="W":
print("incorrect")
exit()
print("correct")
posted:
last update: