When it is Scissor and Paper, you should swap al[0] and al[1], assuming 
al[0] always beat al[1]

*T = int(input())*
*t = 1*
*cas = ["P","R","S"]*
*while(t <= T):*
*    res = ""*
*    A = int(input())*
*    l = []*
*    for i in range(A):*
*        l.append(input())*
*    pos = 0*
*    while(len(l) > 0):*
*        al = []*
*        for i in l:*
*            if(i[pos%len(i)] not in al):*
*                al.append(i[pos%len(i)])*
*        if len(al) == 1:*
*            res += cas[(cas.index(al[0])-1)%3]*
*            l.clear()*
*        elif len(al) == 3:*
*            res = "IMPOSSIBLE"*
*            l.clear()*
*        else:*
*            al = sorted(al)*
*            if al[1] == "S" and al[0] == "P":*
*                res += "S"*
*                # Swap al[0] and al[1] when it is Scissor and Paper*
*                al[0], al[1] = al[1], al[0]*
*            else:*
*                res += al[0]*
*            l = list(filter(lambda x: x[pos%len(x)] != al[1],l))*
*            pos += 1*
*    print("Case #{}: {}".format(t, res))*
*    t += 1*

-- 
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/72c122a0-ccef-4a5b-929f-983e769f6cd6%40googlegroups.com.

Reply via email to