Hi all 
I have seen an interesting solution for parenting partners 
sort the time according to this format 

Input: 

1
3
360 480
420 540
600 660

sort like this 

(360,s,1),(420,s,2),(480,e,1),(540,e,1),(600,s,3),(600,s,3)

Then assign it to 'c' and 'j' according to the sorted list when you 
encounter e then pop that time from 'c' or 'j'

as mentioned in this videohttps://www.youtube.com/watch?v=QfFo_MinRs8 

I wrote a python script for this 




def assign_c_j(data):
    c = [False,[]]
    j = [False,[]]
    s1 = ""
    for i in data:
        
        if i[1] == "s" and c[0] == False:
            c[0] = True
            c[1].append(i[2])
            s1+="C"
        elif i[1] == "s" and j[0] == False:
            j[0] = True
            j[1].append(i[2])
            s1+="J"
        elif i[1] == "s" and (c[0] == True and j[0] == True):
            return "IMPOSSIBLE"
        elif i[1] == "e":
            if i[2] in c[1]:
                c[0] = False
                c[1].remove(i[2])
            elif i[2] in j[1]:
                j[0] = False
                j[1].remove(i[2])
        # print("c",c)
        # print("j",j)
    
    return s1
if __name__ == "__main__":
    for a in range(int(input())):
        data = []
        
        tracker = {}
        temp = []
        for b1 in range(int(input())):
            s , e = map(int,input().split())
            data.append([s,'s',b1])
            data.append([e,'e',b1])
        data.sort()
        print("Case #"+str(a+1)+":",assign_c_j(data))

Output was:
Case #1: CJC
Case #2:IMPOSSIBLE
Case #3: JCCJJ
Case #4: CC

when you observe case 3 the code jam solution was different and code 
produced a different result which is not wrong. when you do it by hand.

It is promoting me with this  error message

Sample Failed: WA

any help is most appreciated 
thank you 
regards 
M Pranay

-- 
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/0a58f935-5e29-413c-92f3-6932221ed5fc%40googlegroups.com.

Reply via email to