H all,

I started practicing some previous GCJ problems in preperation for GCJ 
2020, I'm getting a TLE error on the first set on my submitted code, 
however the time limit is specified as 20 seconds per set,running my code 
locally it takes less that one second removing the time it takes me to type 
down the inputs.

Any help is appreciated,

code:
=======================================

def next_prime(a, n):
    for number in range(a+1, n):
        if (number % 2 == 0) or (number % 3 == 0):
            continue
        i = 5
        while i*i <= number:
            if number % i == 0 or number % (i + 2) == 0:
                i += 6
                continue
            i += 6
        return number


def main():
    t = input()
    for x in range(int(t)):
        n, l = input().split(' ')
        n = int(n)
        l = int(l)
        ans = ''
        pangram = dict()
        prime_list = []

        p = input().split(' ')
        a = 3
        while int(p[0]) % a != 0:
            a = next_prime(a, n)

        if int(p[1]) % a != 0:
            prime_list.append(a)
            prime_list.append(int(p[0])/a)
        else:
            prime_list.append(int(p[0])/a)
            prime_list.append(a)

        for i in range(1, len(p)):
            num = int(p[i])
            prime_list.append(num/prime_list[-1])

        sorted_list = prime_list.copy()
        sorted_list = list(dict.fromkeys(sorted_list))
        sorted_list.sort()
        alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        for num in range(len(alphabets)):
            pangram[sorted_list[num]] = alphabets[num]

        for prime in prime_list:
            ans += str(pangram.get(prime))
        print('Case #' + str(x + 1) + ': ' + ans)

main()


===============================

-- 
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/e210f8cf-2ac9-46fa-9bd7-f4d454dedabb%40googlegroups.com.

Reply via email to