Submission #175602


Source Code Expand

from copy import deepcopy
k, m = map(int, raw_input().split())
a = map(int, raw_input().split())
c = map(int, raw_input().split())
mat = [[0 for i in xrange(k)] for j in xrange(k)]
# [ C1 C2 ... C(K-1) CK ]
# [  1  0 ...    0    0 ]
# [  0  1 ...    0    0 ]
# [  :  :        :    : ]
# [  0  0 ...    1    0 ]
#
# ( 1 <- (FFFFFFFF)_16 )
for i in xrange(k):
    mat[0][i] = c[i]
for i in xrange(k-1):
    mat[i+1][i] = int("FFFFFFFF", 16)
# identify matrix ( 1 <- (FFFFFFFF)_16 )
mat_a = [[int("FFFFFFFF", 16) if i==j else 0 for i in xrange(k)] for j in xrange(k)]

if m<=k:
    print a[m-1]
else:
    m -= k
    mat_d = [[0 for i in xrange(k)] for j in xrange(k)]
    mat2 = [[0 for i in xrange(k)] for j in xrange(k)]
    while m>0:
        if m%2==1:
            for i in xrange(k):
                for j in xrange(k):
                    mat_d[i][j] = 0
                    for l in xrange(k):
                        mat_d[i][j] ^= (mat_a[i][l] & mat[l][j])
            mat_a = deepcopy(mat_d)
        for i in xrange(k):
            for j in xrange(k):
                mat2[i][j] = 0
                for l in xrange(k):
                    mat2[i][j] ^= (mat[i][l] & mat[l][j])
        mat = deepcopy(mat2)
        m /= 2
    ans = 0
    for i in xrange(k):
        ans ^= (mat_a[0][i] & a[k-i-1])
    print ans

Submission Info

Submission Time
Task D - 漸化式
User yaketake08
Language Python (2.7.3)
Score 0
Code Size 1362 Byte
Status TLE
Exec Time 2031 ms
Memory 4184 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 9
TLE × 8
Set Name Test Cases
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, small_1.txt, small_2.txt
Case Name Status Exec Time Memory
random_01.txt AC 129 ms 3512 KB
random_02.txt AC 59 ms 3444 KB
random_03.txt AC 48 ms 3448 KB
random_04.txt AC 48 ms 3504 KB
random_05.txt AC 49 ms 3508 KB
random_06.txt AC 57 ms 3508 KB
random_07.txt AC 925 ms 3748 KB
random_08.txt TLE 2029 ms 4184 KB
random_09.txt TLE 2031 ms 4004 KB
random_10.txt TLE 2030 ms 4084 KB
random_11.txt TLE 2030 ms 4080 KB
random_12.txt TLE 2030 ms 3996 KB
random_13.txt TLE 2030 ms 4072 KB
random_14.txt TLE 2031 ms 4008 KB
random_15.txt TLE 2030 ms 4056 KB
sample_1.txt AC 50 ms 3432 KB
sample_2.txt AC 53 ms 3512 KB
sample_3.txt AC 773 ms 3548 KB
small_1.txt AC 51 ms 3512 KB
small_2.txt AC 50 ms 3452 KB