This is the final code which clears all test cases. T = int(input()) for i in range(1,T+1): N=int(input()) jobs=[] for x in range(N): jobs.append(tuple(map(int, input().split(' ')))+(x,))
L = [0]*N cj=[0,0] m = sorted(jobs) imp = False for j in m: if j[0] >= cj[0]: L[j[2]] = 'C' cj[0] = j[1] elif j[0] >= cj[1]: L[j[2]] = 'J' cj[1] = j[1] else: imp = True break if imp==True: print("Case #{}: IMPOSSIBLE".format(i)) else: print("Case #{}: {}".format(i,''.join(L))) -- 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 google-code+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/c2782d78-67ed-4b07-bbb0-c10f8c310ae9%40googlegroups.com.