I keep getting WA for this. Not sure if I misunderstood or missed an edge
case. Code in Python3. It was clearing sample code.
def is_overlap(num1, num2):
firstNum, lastNum = None,None
if num1[0] < num2[0]:
firstNum = num1
lastNum = num2
else:
firstNum = num2
lastNum = num1
if lastNum[0] < firstNum[1]:
return True
return False
#total cases
T = int(input())
for case in range(1,T+1):
# read N
N = int(input())
#read schedules
schedules = None
schedules = []
for i in range(0,N):
schedules.append(list(map(int,input().split())))
C = [[1444,-10]]
J = [[1444,-10]]
output = None
output = []
tcount = 0
covered = []
for task in schedules:
#Check for C
for C_task in C:
if is_overlap(C_task,task):
break
else:
output += ['C']
tcount += 1
C.append(task)
covered.append(task)
continue
for J_task in J:
if is_overlap(J_task,task):
break
else:
output += ['J']
J.append(task)
tcount += 1
covered.append(task)
if len(covered) != N :
output = None
output = list('IMPOSSIBLE')
op1 = ''.join(output)
if op1 != 'IMPOSSIBLE' and len(op1) != N:
raise Exception("Length error")
print('Case #{}: {}'.format(case,op1))
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/0e410796-c0b3-4863-9621-a3bcf868357d%40googlegroups.com.