Here is my solution to the problem. It works on sample test case but not on actual ones. The judge returns WA with test set skipped error. Please point out a mistake if you can find. I can't find what I missed even after reading the analysis.
def solve(actv, N): out = '' owner = {} for item in actv: owner[item] = '' sort_copy = actv[:] sort_copy.sort() lastC = () lastJ = () for each in sort_copy: if len(lastC)==0 or each[0]>=lastC[1]: lastC = each owner[each]='C' elif len(lastJ)==0 or each[0]>=lastJ[1]: lastJ = each owner[each]='J' else: return 'IMPOSSIBLE' for i in actv: out+=owner[i] return out def takeInput(): T = int(input()) for i in range(T): N = int(input()) actv = [] for j in range(N): S, E = tuple(map(int, input().split())) actv.append((S,E)) result = solve(actv, N) print('Case #{}: '.format(i+1)+result) takeInput() -- 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/f20e66f7-0d9b-4ccc-8512-b484def4cfff%40googlegroups.com.