Submission #7803795
Source Code Expand
Copy
import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinessys.setrecursionlimit(10 ** 7)import numpy as npK,M = map(int,readline().split())A = np.array(readline().split(),np.int64)C = np.array(readline().split(),np.int64)A,CKmask = (1<<32)-1mat = np.eye(K,K,-1,np.int64) * maskmat[0] = Cdef mat_prod(A,B):
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) import numpy as np K,M = map(int,readline().split()) A = np.array(readline().split(),np.int64) C = np.array(readline().split(),np.int64) A,C K mask = (1<<32)-1 mat = np.eye(K,K,-1,np.int64) * mask mat[0] = C def mat_prod(A,B): a,b = A.shape c,d = B.shape assert b == c return np.bitwise_xor.reduce(A[:,:,None] & B[None,:,:],axis=1) def mat_power(A,N): if N == 0: return np.eye(K,dtype=np.int64) * mask mat = mat_power(A,N//2) mat = mat_prod(mat,mat) return mat_prod(mat,A) if N&1 else mat x = mat_power(mat,M-1) v = mat_prod(x,A[::-1].reshape(-1,1)) answer = v[-1,0] print(answer)
Submission Info
Submission Time | |
---|---|
Task | D - 漸化式 |
User | maspy |
Language | Python (3.4.3) |
Score | 100 |
Code Size | 811 Byte |
Status | AC |
Exec Time | 303 ms |
Memory | 20592 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
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, sample_1.txt, sample_2.txt, sample_3.txt, small_1.txt, small_2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
random_01.txt | AC | 149 ms | 12508 KB |
random_02.txt | AC | 148 ms | 12424 KB |
random_03.txt | AC | 149 ms | 12424 KB |
random_04.txt | AC | 148 ms | 12384 KB |
random_05.txt | AC | 150 ms | 12428 KB |
random_06.txt | AC | 149 ms | 12428 KB |
random_07.txt | AC | 155 ms | 12876 KB |
random_08.txt | AC | 173 ms | 13560 KB |
random_09.txt | AC | 294 ms | 20348 KB |
random_10.txt | AC | 301 ms | 20560 KB |
random_11.txt | AC | 302 ms | 20560 KB |
random_12.txt | AC | 302 ms | 20476 KB |
random_13.txt | AC | 302 ms | 20592 KB |
random_14.txt | AC | 303 ms | 20560 KB |
random_15.txt | AC | 282 ms | 20476 KB |
sample_1.txt | AC | 148 ms | 12512 KB |
sample_2.txt | AC | 148 ms | 12428 KB |
sample_3.txt | AC | 155 ms | 12796 KB |
small_1.txt | AC | 150 ms | 12428 KB |
small_2.txt | AC | 150 ms | 12424 KB |