I will try to make you understand through a test case. Input: 360 720 100 260 250 350 Output: CJC
the last part runs first and gets completed before 360 starts. I think this will make u understand why you need to sort. On Tuesday, April 7, 2020 at 10:26:02 PM UTC+5:30, AC wrote: > > Hi Bhavesh, > > Do we know why are we trying to sort the start time. > Since we do have to put the output in same order as we received it. > Is this a tie breaker condition for multiple solutions? > Can u share the edge cases for this. > > Thanks, > > On Tue, Apr 7, 2020 at 8:51 AM Bhavesh Kumar <bhavesh...@gmail.com > <javascript:>> wrote: > >> Yes, I solved in Python. Idea is simple, maintain a list of tuples. Each >> tuple will have three values (start_time, end_time, index). now sort the >> list based on first value. Checkout the code below. >> >> for t in range(int(input())): >> N = int(input()) >> A = [] >> for i in range(N): >> s, e = map(int, input().split()) >> A.append((s, e, i)) >> >> A.sort() >> ans = ['X'] * N >> C, J = None, None >> for x in A: >> if C is not None: >> if C[1] <= x[0]: >> C = None >> >> if J is not None: >> if J[1] <= x[0]: >> J = None >> >> if C is None: >> C = x >> ans[x[2]] = "C" >> >> elif J is None: >> J = x >> ans[x[2]] = "J" >> >> else: >> ans = "IMPOSSIBLE" >> break >> >> >> if 'X' in ans: >> ans = "IMPOSSIBLE" >> >> if isinstance(ans, list): >> ans = "".join(ans) >> >> print("Case #{}: {}".format(t+1, ans)) >> >> >> >> >> >> >> >> On Tuesday, 7 April 2020 06:20:28 UTC+5:30, Martin Seeler wrote: >>> >>> I'm asking to keep my sanity: Did anyone solve this problem with Python? >>> I can't find these tricky edge cases where my code fails, all variations >>> I try on my machine seem to work just fine. Still CodeJam Environment says >>> *WA*. >>> >>> If there is someone who solved it in python, then I know I'm missing >>> some cases. Otherwise I start to question the environment :D >>> >>> Thanks and have a nice day everyone >>> >> -- >> 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 googl...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/google-code/034a5111-e44e-4a02-8f8b-7d8791e89a7a%40googlegroups.com >> >> <https://groups.google.com/d/msgid/google-code/034a5111-e44e-4a02-8f8b-7d8791e89a7a%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > Cheers! > Aabhas > > -- 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/3dd3f668-be55-400b-b521-96592ef9a08b%40googlegroups.com.