• + 0 comments

    Changing lists to sets worked. Yeah, when I was choosing which type to use I kinda wanted something like SortedSet(http://www.grantjenks.com/docs/sortedcontainers/index.html), but when I didn't find it in the stock library I felt that sorting was more important and set has no order so I used lists with sorting. Now that I think about it after looking at your calculations, I feel silly for thinking that. If a list is used the size of states or len(states) actually reaches 2**N or 1e30 in worst case - if N is set to 100 and G is sufficiently large(>sum(A)). And if you remove duplicates e.g. by using a set, then the size is limited by what's it members can be - from 0 to A*N or 100*100=10 000 in worst case,i.e. no more than 10 001 members... So yeah, thanks for the advice m8.