Hi,
It's working fine with all kind of test cases in my console, but showed WA
error in code jam.
Can you please comment on my approach:

t=int(input())for i in range(t):
    n=int(input())
    clist=[]
    jlist=[]
    ans=''
    for j in range(n):
        tempsl=list(map(int,input().strip().split(' ')))
        intempsl=list(range(tempsl[0],tempsl[1]))
        if set(clist).isdisjoint(set(intempsl)):
            ans+='C'
            clist+=intempsl
        elif set(jlist).isdisjoint(set(intempsl)):
            ans+='J'
            jlist+=intempsl
        else:
            ans='IMPOSSIBLE'
            break
    print('Case #'+str(i+1)+':',ans)


On Tue, 7 Apr, 2020, 6:36 AM Denys Halachian, <xlin...@gmail.com> wrote:

> I hope its help,
>
> from functools import reduce
>
> class Solver(object):
>     def __init__(self):
>         super().__init__()
>
>     def find_distribution(self, intervals):
>         _intervals = list(intervals)
>         intervals.sort(key=lambda x: x[0])
>
>         mp = {}
>         J = 0
>         C = 0
>         for e in intervals:
>             tp = (e[0], e[1])
>             if tp not in mp:
>                 mp[tp] = [0]
>             if J <= e[0]:
>                 J = e[1]
>                 mp[tp].append('J')
>                 mp[tp][0] += 1
>             elif C <= e[0]:
>                 C = e[1]
>                 mp[tp].append('C')
>                 mp[tp][0] += 1
>             else:
>                 return 'IMPOSSIBLE'
>
>         sq = ''
>         for e in _intervals:
>             tp = (e[0], e[1])
>             sq += mp[tp][mp[tp][0]]
>             mp[tp][0] -= 1
>         return sq
>
> def main():
>     solver = Solver()
>     T = int(input())
>     for t in range(T):
>         n = int(input())
>         intervals = []
>         for _ in range(n):
>             intervals.append([int(e) for e in input().split()])
>         print('Case #%d: %s' % (t + 1,
> solver.find_distribution(intervals)))
>     return 0
>
> if __name__ == "__main__":
>     main()
>
> On Apr 4, 2020, at 11:54, Martin Seeler <martin.see...@gmail.com> 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 google-code+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/d7192abb-1170-491e-9ad4-ac0d8f7978c7%40googlegroups.com
> <https://groups.google.com/d/msgid/google-code/d7192abb-1170-491e-9ad4-ac0d8f7978c7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
> --
> 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/10B8115C-2D91-476C-8D49-EE3CF1BFBDCC%40gmail.com
> <https://groups.google.com/d/msgid/google-code/10B8115C-2D91-476C-8D49-EE3CF1BFBDCC%40gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAAFVOY1VmzWEG6AwytpmazBosDYhCqrrOfO1BQXnuVhezNVpTA%40mail.gmail.com.

Reply via email to