Created
October 4, 2016 22:23
-
-
Save benblack769/0d5640f72c90094546d75b7e362e2988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
#table=[[[None]*101]*101]*101 | |
table = [[[None for k in range(101)] for j in range(101)] for i in range(101)] | |
table[0][0][0] = True | |
data_table = [[[None for k in range(101)] for j in range(101)] for i in range(101)] | |
def vals(coord0,coord1,coord2): | |
t0 = table[coord0] | |
t1 = t0[coord1] | |
for x in range(coord0-1,coord1-1,-1): | |
if not table[x][coord1][coord2]: | |
return [True,x,0] | |
for x in range(coord1-1,coord2-1,-1): | |
if not table[x][x][coord2]: | |
return [True,x,0] | |
for x in range(coord2-1,-1,-1): | |
if not table[x][x][x]: | |
return [True,x,0] | |
for x in range(coord1-1,coord2-1,-1): | |
if not t0[x][coord2]: | |
return [True,x,1] | |
for x in range(coord2-1,-1,-1): | |
if not t0[x][x]: | |
return [True,x,1] | |
for x in range(coord2-1,-1,-1): | |
if not t1[x]: | |
return [True,x,2] | |
return [False,0,0] | |
for i in range(1,101): | |
for j in range(i+1): | |
for k in range(j+1): | |
val,x,y = vals(i,j,k) | |
table[i][j][k] = val | |
data_table[i][j][k] = (x,y) | |
cases = int(input()) | |
for case in range(cases): | |
ls = [int(x) for x in input().split()] | |
result = table[ls[1]][ls[2]][ls[3]] | |
datares = data_table[ls[1]][ls[2]][ls[3]] | |
if result == True: | |
print(str(case + 1) + " W " + str(datares[0]+1) + " " + str(datares[1]+1)) | |
else: | |
print(str(case + 1) + " L") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment