Submission #175238


Source Code Expand

#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
from collections import defaultdict

K,M = map(int, sys.stdin.readline().rstrip().split())
As = map(int, sys.stdin.readline().rstrip().split())
Cs = map(int, sys.stdin.readline().rstrip().split())

starti = len(As)
term = 1
for i in xrange(len(As), len(As)+100000):
    #print format(As[-1], 'b')
    restk = i % len(Cs)
    As.append(reduce(lambda x,y: x^y, [(Cs[j-1]&As[i-j]) for j in xrange(1, K+1)]))
    if i>starti+100 and As[starti+1] == As[i] and As[starti] == As[i-1]:
        term = i - starti - 1
        break

#print "term",term
#print As
print As[(M-1)%term]

exit(0)

Submission Info

Submission Time
Task D - 漸化式
User hiking
Language Python (2.7.3)
Score 0
Code Size 672 Byte
Status WA
Exec Time 2032 ms
Memory 6820 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 5
WA × 4
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 73 ms 3604 KB
random_02.txt AC 105 ms 3944 KB
random_03.txt WA 568 ms 6696 KB
random_04.txt WA 669 ms 6820 KB
random_05.txt AC 721 ms 6632 KB
random_06.txt WA 906 ms 6632 KB
random_07.txt WA 1698 ms 6808 KB
random_08.txt TLE 2032 ms 6196 KB
random_09.txt TLE 2030 ms 4964 KB
random_10.txt TLE 2030 ms 4968 KB
random_11.txt TLE 2030 ms 5044 KB
random_12.txt TLE 2031 ms 4964 KB
random_13.txt TLE 2030 ms 5016 KB
random_14.txt TLE 2030 ms 5012 KB
random_15.txt TLE 2030 ms 5012 KB
sample_1.txt AC 52 ms 3612 KB
sample_2.txt AC 50 ms 3612 KB
sample_3.txt WA 1610 ms 6684 KB
small_1.txt AC 51 ms 3616 KB
small_2.txt AC 52 ms 3612 KB