Problem:


バトンリレーゲーム

アカベ高校では、毎年全校生徒が参加するゲームを行っています。まず、校庭に N 人の全校生徒が円形に並びます。図のように、各生徒は 0 から N-1 までの番号が書かれたゼッケンを付けています。

ゲームではバトンを１本使い、最初はゼッケン 0 番の生徒がバトンを持っています。そこから、以下の手順を M  回繰り返します。まず、現時点でバトンを持っている生徒が適当な正の整数 a を宣言します。a が偶数のときは時計回り、奇数のときは反時計回りに隣の生徒にバトンを渡していき、a 番目にバトンを受け取った生徒が脱落します。脱落した生徒は、時計回りで隣の生徒にバトンを渡し、円から抜けます。

ゲームが終わった後に円に残った生徒は、放課後の掃除が１年間免除されます。しかし、ここ数年は生徒数が増えたため、全校生徒を集めるのが難しくなってきています。そこで、競技プログラミング部のあなたは、シミュレーションで掃除が免除される生徒を求めるプログラムを作成するよう頼まれました。

指定した生徒が掃除を免除されているかどうかを質問したとき、それに答えるプログラムを作成してください。

入力

入力は以下の形式で与えられる。 

N M Q
a1 a2 ... aM
q1 q2 ... qQ 

入力は３行であり、１行目に生徒の人数 N (10 ≤ N ≤ 200000)、繰り返し回数 M (5 ≤ M < N)、生徒が掃除を免除されるかどうかを問い合わせる質問の個数 Q (1 ≤ Q ≤ 1000) が与えられる。続く１行に、i 回目の繰り返しで最初にバトンを持っている生徒が宣言する整数ai (1 ≤ ai ≤ 100) が与えられる。続く１行に、質問としてゼッケン番号 qi (0 ≤ q < N) が与えられる。

出力

質問ごとに、ゼッケン番号 qi の生徒が掃除を免除されるかどうかを i 行目に出力する。掃除が免除されるなら 1 を、されないなら 0 を出力する。

入出力例

入力例 

10 5 3
2 6 5 18 3
3 0 5

出力例

1
0
1 



Sample input:
10 5 3
2 6 5 18 3
3 0 5


Sample output:
1
0
1

Submission status: Wrong Answer

Solution code:
import sys
f = sys.stdin

def is_odd(num):
    return num % 2

n,_,_ = map(int,f.readline().split())#_は読み飛ばし
a = list(map(int, f.readline().split()))
q = list(map(int, f.readline().split()))

students = list(range(n))

pos = 0
for ai in a:
    pos += -ai if is_odd(ai) else ai
    pos %= len(students)
    students = students[:pos] + students[pos + 1:]
    pos -= 1

for qi in q:
    print(1 if qi in students else 0)

Submission status: Wrong Answer

Solution code:
import sys
f = sys.stdin

def is_odd(num):
    return num % 2

n,_,_ = map(int,f.readline().split())#_は読み飛ばし
a = list(map(int, f.readline().split()))
q = list(map(int, f.readline().split()))

students = list(range(n))

pos = 0
for ai in a:
    pos += -ai if is_odd(ai) else ai
    pos %= len(students)
    students = students[:pos] + students[pos + 1:]
    print(pos,students)

for qi in q:
    print(1 if qi in students else 0)

Submission status: Wrong Answer

Solution code:
import sys
f = sys.stdin

def is_odd(num):
    return num % 2

n,_,_ = map(int,f.readline().split())#_は読み飛ばし
a = list(map(int, f.readline().split()))
q = list(map(int, f.readline().split()))

s = [1 for _ in range(n)]

pos = 0
for ai in a:
    i = -1 if is_odd(ai) else 1
    while ai:
        pos += i
        pos %= len(s)
        ai -= s[pos]
    s[pos] = 0
    pos += 1

for qi in q:
    print(s[qi])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def pass_baton(n_list, current, in_data):
    print(current, in_data)
    if in_data % 2 != 0:
        current -= in_data
        while current < 0:
            current += len(n_list)
        return current

    else:
        current += in_data
        while len(n_list) <= current:
            current -= len(n_list)
        return current

N, M, Q  = map(int ,input().split(' '))

m_data = map(int, input().split(' '))
q_data = map(int, input().split(' '))

n_list = [x for x in range(N)]
baton_place  = 0
for m in m_data:
    baton_place = pass_baton(n_list, baton_place, m)
    print(baton_place)
    del n_list[baton_place]
    if len(n_list) == baton_place:
        baton_place = 0

for q in q_data:
    if q in n_list:
        print(1)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    # members = list(range(10))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = list(range(N))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]

    l = len(members)
    baton = 0
    for n in numbers:

        if n % 2 == 0:
            n += baton
            n = n % l
            del members[n:n+1]
            baton = n
        else:
            n += baton
            n = n % l
            del members[l-n:l-n+1]
            baton = l-n
        l -= 1

    for q in queries:
        if q in members:
            print(1)
        else:
            print(0)




if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301

"""
import sys
from sys import stdin
input = stdin.readline


def remove_member(members, baton, count):
    l = len(members)
    if count % 2 == 0:
        t = baton + count
        t %= l
        if t != l:
            del members[t:t+1]
            return t
        else:
            members = members[:-1]
            return 0
    else:
        t = baton - count
        if t >= 0:
            del members[t:t+1]
            return t
        else:
            if t == -1:
                members = members[:-1]
                return 0
            else:
                del members[t:t+1]
                return t+1


def main(args):
    # members = list(range(10))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = list(range(N))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]

    baton = 0
    for n in numbers:
        res = remove_member(members, baton, n)
        baton = res

    for q in queries:
        if q in members:
            print(1)
        else:
            print(0)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301
WA
"""
import sys
from sys import stdin
input = stdin.readline


def remove_member(members, baton, count):
    l = len(members)
    if count % 2 == 0:
        t = baton + count
        t %= l
        if t != l:
            del members[t:t+1]
            return t % (l - 1)
        else:
            members = members[:-1]
            return 0
    else:
        t = baton - count
        if t >= 0:
            del members[t:t+1]
            return t
        else:
            if t == -1:
                members = members[:-1]
                return 0
            else:
                del members[t:t+1]
                return t % l


def main(args):
    # members = list(range(10))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = list(range(N))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]

    baton = 0
    for n in numbers:
        res = remove_member(members, baton, n)
        baton = res

    for q in queries:
        ans = 1 if q in members else 0
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301
WA
"""
import sys
from sys import stdin
input = stdin.readline


def remove_member(members, baton, count):
    l = len(members)
    if count % 2 == 0:
        t = baton + count
        t %= l
        if t != (l-1):
            del members[t:t+1]
            return t % (l - 1)
        else:
            del members[l-1:l]
            return 0
    else:
        t = baton - count
        if t >= 0:
            del members[t:t+1]
            return t
        else:
            if t == -1:
                del members[l-1:l]
                return 0
            else:
                u = l - abs(t)
                del members[u:u+1]
                return u % (l - 1)


def main(args):
    # members = list(range(10))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = list(range(N))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]

    baton = 0
    for n in numbers:
        res = remove_member(members, baton, n)
        baton = res

    for q in queries:
        ans = 1 if q in members else 0
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
N,M,Q = map(int,input().split())

a = list(map(int,input().split()))
q = map(int,input().split())

t = [ 1 for i in range(N) ]
i = 0
for m in range(M):
    if a[m] % 2 == 1:
        s = -1
    else:
        s =  1
    aa = a[m]

    while aa > 0:
        i = (i + s) % N
        if t[i] == 1:
            aa -= 1
    t[i] = 0
    i = (i + 1) % N

for i in q:
    print(t[i])

Submission status: Wrong Answer

Solution code:
def solve():
    import sys
    file_input = sys.stdin
    
    N, M, Q = map(int, file_input.readline().split())
    
    student = list(range(N))
    exemption = [1] * N
    pos = 0
    for a in map(int, file_input.readline().split()):
        if a % 2:
            pos = (pos - a) % len(student)
        else:
            pos = (pos + a) % len(student)
        s = student[pos]
        exemption[s] = 0
        del student[pos]
        pos += 1
    
    Q = map(int, file_input.readline().split())
    print(*map(lambda x:exemption[x], Q), sep = '\n')

solve()

Submission status: Wrong Answer

Solution code:
n, m, q = map(int, input().split())
s = [i for i in range(n)]
a = tuple(map(int, input().split()))
b = 0
for i in a:
    if i % 2:
        b = (b + i) % len(s)
        s.pop(b)
    else:
        b = (b - i) % len(s)
        s.pop(b)
r = tuple(map(int, input().split()))
for i in r:
    print(1 if i in s else 0)

Submission status: Time Limit Exceeded

Solution code:
import sys
f = sys.stdin

def is_odd(num):
    return num % 2

n,_,_ = map(int,f.readline().split())#_は読み飛ばし
a = list(map(int, f.readline().split()))
q = list(map(int, f.readline().split()))

students = list(range(n))

pos = 0
for ai in a:
    pos += -ai if is_odd(ai) else ai
    pos %= len(students)
    students = students[:pos] + students[pos + 1:]

for qi in q:
    print(1 if qi in students else 0)

Submission status: Time Limit Exceeded

Solution code:
n, m, _ = map(int, input().split())
n0 = n
exem = [1] * n0
i = 0

for a in map(int, input().split()):
    is_even = not a & 1
    a %= n
    if is_even: a = n - a
    c = 0
    while a:
        c += 1
        if exem[i - c]:
            a -= 1
    exem[i - c] = 0
    i = (i - c + 1) % n0
    n -= 1

for q in map(int, input().split()):
    print(exem[q])

Submission status: Time Limit Exceeded

Solution code:
N,M,Q = map(int,input().split())

a = list(map(int,input().split()))
q = map(int,input().split())

t = [ 1 for i in range(N) ]
i = 0
for m in range(M):
    if a[m] % 2 == 1:
        s = -1
    else:
        s =  1
    aa = a[m]

    while aa > 0:
        i = (i + s) % N
        if t[i] == 1:
            aa -= 1
    t[i] = 0
    while True:
        i = (i + 1) % N
        if t[i] == 1:
            break;
for i in q:
    print(t[i])

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

def is_odd(num):
    return num % 2

n,_,_ = map(int,f.readline().split())#_は読み飛ばし
a = list(map(int, f.readline().split()))
q = list(map(int, f.readline().split()))

s = list(range(n))

pos = 0
for ai in a:
    pos += -ai if is_odd(ai) else ai
    pos %= len(s)
    s.pop(pos)

for qi in q:
    print(1 if qi in s else 0)

Submission status: Accepted

Solution code:
import sys
f=sys.stdin

n,_,_=map(int,f.readline().split())
a=list(map(int,f.readline().split()))
q=list(map(int,f.readline().split()))
s=list(range(n))

pos=0
for ai in a:
    if ai%2:
        pos+=-ai
    else:
        pos+=ai
    pos%=len(s)
    s.pop(pos)
for qi in q:
    print 1 if qi in s else 0

Submission status: Accepted

Solution code:
n, m, _ = map(int, input().split())
exem = list(range(n))
i = 0

for a in map(int, input().split()):
    is_odd = a & 1
    i += -a if a & 1 else a
    i %= n
    exem.pop(i)
    n -= 1

for q in map(int, input().split()):
    print(int(q in exem))

Submission status: Accepted

Solution code:
n, m, _ = map(int, input().split())
exem = list(range(n))
i = 0

for a in map(int, input().split()):
    is_odd = a & 1
    i += -a if a & 1 else a
    i %= n
    exem.pop(i)
    n -= 1

exem = set(exem)
for q in map(int, input().split()):
    print(int(q in exem))

Submission status: Accepted

Solution code:
n,_,_=map(int,input().split())
a,b=list(range(n)),0
for i in map(int,input().split()):
    b-= i if i&1 else -i
    b%=n
    del a[b]
    n-=1
for i in map(int,input().split()):
    print(int(i in a))

Submission status: Accepted

Solution code:

def pass_baton(n_list, current, in_data):
    if in_data % 2 != 0:
        current -= in_data
        while current < 0:
            current += len(n_list)
        return current

    else:
        current += in_data
        while len(n_list) <= current:
            current -= len(n_list)
        return current

N, M, Q  = map(int ,input().split(' '))

m_data = map(int, input().split(' '))
q_data = map(int, input().split(' '))

n_list = [x for x in range(N)]
baton_place  = 0
for m in m_data:
    baton_place = pass_baton(n_list, baton_place, m)
    del n_list[baton_place]

for q in q_data:
    if q in n_list:
        print(1)
    else:
        print(0)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301
WA
"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def main(args):
    # members = deque(list(range(10)))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = deque(list(range(N)))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]


    for n in numbers:
        if n % 2 == 0:
            n = n % N
            members.rotate(-n)
            members.popleft()
        else:
            n = n % N
            members.rotate(n)
            members.popleft()
        N -= 1


    for q in queries:
        ans = 1 if q in members else 0
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def main(args):
    # members = deque(list(range(10)))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = deque(list(range(N)))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]

    for n in numbers:
        if n % 2 == 0:
            # n = n % N
            members.rotate(-n)
            members.popleft()
        else:
            # n = n % N
            members.rotate(n)
            members.popleft()
        N -= 1

    for q in queries:
        ans = 1 if q in members else 0
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
N,M,Q = map(int,input().split())

a = map(int,input().split())
q = map(int,input().split())

t = [ i for i in range(N) ]
n = N
i = 0
for aa in a:
    if aa % 2 == 1:
        i = (i - aa) % n
    else:
        i = (i + aa) % n
    del t[i]
    n -= 1
    
for i in q:
    if i in t:
        print(1)
    else:
        print(0)

Submission status: Accepted

Solution code:
def solve():
    import sys
    file_input = sys.stdin
    
    N, M, Q = map(int, file_input.readline().split())
    
    student = list(range(N))
    exemption = [1] * N
    pos = 0
    for a in map(int, file_input.readline().split()):
        if a % 2:
            pos = (pos - a) % len(student)
        else:
            pos = (pos + a) % len(student)
        s = student[pos]
        exemption[s] = 0
        del student[pos]
    
    question = map(int, file_input.readline().split())
    print(*map(lambda x:exemption[x], question), sep = '\n')

solve()

Submission status: Accepted

Solution code:
def solve():
    import sys
    file_input = sys.stdin
    
    N, M, Q = map(int, file_input.readline().split())
    
    from collections import deque
    student = deque(range(N))
    exemption = [1] * N
    for a in map(int, file_input.readline().split()):
        if a % 2:
            student.rotate(a)
        else:
            student.rotate(-a)
        s = student.popleft()
        exemption[s] = 0
    
    question = map(int, file_input.readline().split())
    print(*map(lambda x: exemption[x], question), sep = '\n')

solve()

Submission status: Accepted

Solution code:
n = list(map(int, input().split()))[0]
s = [i for i in range(n)]
a = tuple(map(int, input().split()))
b = 0
for i in a:
    if i % 2:
        b = (b - i) % len(s)
        s.pop(b)
    else:
        b = (b + i) % len(s)
        s.pop(b)
r = tuple(map(int, input().split()))
for i in r:
    print(1 if i in s else 0)

Submission status: Accepted

Solution code:
from bisect import bisect_left as bl

n, m, q = map(int, input().split())
lst = [i for i in range(n)]
alst = list(map(int, input().split()))
ind = 0
for a in alst:
  if a % 2 == 0:
    ind += a
  else:
    ind -= a
  ind = ind % len(lst)
  lst.pop(ind)
  ind = ind % len(lst)

qlst = list(map(int, input().split()))
for q in qlst:
  qi = bl(lst, q)
  if qi >= len(lst):
    print(0)
  else:
    print(int(lst[qi] == q))

Submission status: Accepted

Solution code:
from bisect import bisect_left as bl

n, m, q = map(int, input().split())
lst = [i for i in range(n)]
alst = list(map(int, input().split()))
ind = 0
for a in alst:
  if a % 2 == 0:
    ind += a
  else:
    ind -= a
  ind = ind % len(lst)
  lst.pop(ind)
  ind = ind % len(lst)

qlst = list(map(int, input().split()))
for q in qlst:
  print(int(q in lst))

Submission status: Accepted

Solution code:
N, M, Q = map(int, input().split())
student = []
for i in range(N) :
    student.append(i)
x = 0
a = list(map(int, input().split()))
q = list(map(int, input().split()))

for i in range(M) :
    if a[i] % 2 == 0 : ## 偶数
        x = (x + a[i]) % len(student)
    else : ## 奇数
        x = x - a[i]
        if x < 0 :
            while x < 0 :
                x += len(student)
    del student[x]
    if x == len(student) :
        x = 0
for i in range(Q) :
    if q[i] in student :
        print(1)
    else :
        print(0)

Submission status: Accepted

Solution code:
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301
# 双方向循環リストを使用した実装
from sys import stdin


class DoublyCicularList():

    class Cell():
        def __init__(self, v):
            self.next = None
            self.previous = None
            self.value = v

    def __init__(self):
        self.pos = DoublyCicularList.Cell(0)
        self.pos.next = self.pos
        self.pos.previous = self.pos
        self.head = self.pos


def main():
    N, M, Q = map(lambda x: int(x), stdin.readline().strip().split(' '))
    a_list = map(lambda x: int(x), stdin.readline().strip().split(' '))
    q_list = map(lambda x: int(x), stdin.readline().strip().split(' '))
    dcl = DoublyCicularList()
    for i in range(1, N):
        prev = dcl.pos
        dcl.pos.next = DoublyCicularList.Cell(i)
        dcl.pos = dcl.pos.next
        dcl.pos.previous = prev
        dcl.pos.next = dcl.head
        dcl.head.previous = dcl.pos
    dcl.pos = dcl.head
    for i, a in enumerate(a_list):
        for _ in range(a % (N-i)):
            if a % 2 == 0:
                dcl.pos = dcl.pos.next
            else:
                dcl.pos = dcl.pos.previous
        dcl.pos.previous.next = dcl.pos.next
        dcl.pos.next.previous = dcl.pos.previous
        dcl.pos = dcl.pos.next
    res_list = []
    last_value = dcl.pos.previous.value
    while True:
        if dcl.pos.value == last_value:
            res_list.append(dcl.pos.value)
            break
        res_list.append(dcl.pos.value)
        dcl.pos = dcl.pos.next
    print('\n'.join(['1' if q in res_list else '0' for q in q_list]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M,Q=map(int,input().split())
member=list(range(N))
pos=0
m=list(map(int,input().split()))
for i in m:
    if i%2==0:
        pos+=i
        while pos>=len(member):pos-=len(member)
        del member[pos]
        if pos>len(member):pos=0
    else:
        pos-=i
        while pos<0:pos+=len(member)
        del member[pos]
        if pos>len(member):pos=0
q=list(map(int,input().split()))
for i in q:
    if i in member:
        print("1")
    else:
        print("0")

Submission status: Accepted

Solution code:
n, m, q = map(int, input().split())
alist = list(map(int, input().split()))
qlist = list(map(int, input().split()))

student = list(range(n))
num = 0

for a in alist:
    if a % 2 == 1:
        num = (num - a) % n
    else:
        num = (num + a) % n
    del student[num]
    n -= 1

for q in qlist:
    if q in student:
        print(1)
    else:
        print(0)

Submission status: Accepted

Solution code:
from collections import deque
N,M,Q = map(int,input().split())
st = deque(range(N))
for a in map(int,input().split()):
    st.rotate(((-1)**((a&1)+1))*a)
    st.popleft()
st = set(st)
print("\n".join("1" if q in st else "0" for q in map(int,input().split())))

Submission status: Accepted

Solution code:
import sys
from collections import deque
N, M, Q = map(int, sys.stdin.readline().split())
students = deque(range(N))
rotate, popleft = students.rotate, students.popleft
for n in map(int, sys.stdin.readline().split()):
    rotate(-(n%N if n%2==0 else -n%N))
    popleft()
    N -= 1
students = set(students)
print("\n".join("1" if n in students else "0" for n in map(int, sys.stdin.readline().split())))

Submission status: Runtime Error

Solution code:
N,M,Q = map(int,input().split())
a = []
q = []
b = 0
y = 0

a.append(map(int,inout().split(' ')))
q.append(map(int,inout().split(' ')))

for i in range(M):
	x = a[b]
	if x % 2 == 0:
		y += x
		if y > N:
			y -= N
	else:
		y -= x
		if y < 0:
			y = n + y
	b += 1

b = 0

for j in range(Q):
	z = q[b]
	if z!=y:
		print(1)
	else:
		print(0)
	b += 1

Submission status: Runtime Error

Solution code:
N,M,Q = map(int,input().split())
a = []
q = []
b = 0
y = 0

for c in range(M):
	a.append(input())

for d in range(Q):
	q.append(input())

for i in range(M):
	x = a[b]
	if x % 2 == 0:
		y += x
		if y > N:
			y -= N
	else:
		y -= x
		if y < 0:
			y = n + y
	b += 1

b = 0

for j in range(Q):
	z = q[b]
	if z!=y:
		print(1)
	else:
		print(0)
	b += 1

Submission status: Runtime Error

Solution code:
N,M,Q = map(int,input().split(' '))
a = []
q = []
b = 0
y = 0

for c in range(M):
	a.append(input())

for d in range(Q):
	q.append(input())

for i in range(M):
	x = a[b]
	if x % 2 == 0:
		y += x
		if y > N:
			y -= N
	else:
		y -= x
		if y < 0:
			y = n + y
	b += 1

b = 0

for j in range(Q):
	z = q[b]
	if z!=y:
		print(1)
	else:
		print(0)
	b += 1

Submission status: Runtime Error

Solution code:
N,M,Q = map(int,input().split(' '))
a = []
q = []
b = 0
y = 0

for c in range(M):
	a.append(map(int, raw_input().split(' ')))

for d in range(Q):
	q.append(map(int, raw_input().split(' ')))

for i in range(M):
	x = a[b]
	if x % 2 == 0:
		y += x
		if y > N:
			y -= N
	else:
		y -= x
		if y < 0:
			y = n + y
	b += 1

b = 0

for j in range(Q):
	z = q[b]
	if z!=y:
		print(1)
	else:
		print(0)
	b += 1

Submission status: Runtime Error

Solution code:
N,M,Q = map(int,input().split(' '))
a = []
q = []
b = 0
y = 0

for c in range(M):
	a.append(map(int, raw_input().split()))

for d in range(Q):
	q.append(map(int, raw_input().split()))

for i in range(M):
	x = a[b]
	if x % 2 == 0:
		y += x
		if y > N:
			y -= N
	else:
		y -= x
		if y < 0:
			y = n + y
	b += 1

b = 0

for j in range(Q):
	z = q[b]
	if z!=y:
		print(1)
	else:
		print(0)
	b += 1

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0301
WA
"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def main(args):
    # members = deque(list(range(10)))
    # numbers = [2, 6, 5, 18, 3]
    # queries = [3, 0, 5]

    N, M, Q = map(int, input().split(' '))
    members = list(range(N))
    numbers = [int(x) for x in input().split(' ')]
    queries = [int(x) for x in input().split(' ')]


    for n in numbers:
        if n % 2 == 0:
            members.rotate(-n)
            members.popleft()
        else:
            members.rotate(n)
            members.popleft()


    for q in queries:
        ans = 1 if q in members else 0
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Runtime Error

Solution code:
from bisect import bisect_left as bl

n, m, q = map(int, input().split())
lst = [i for i in range(n)]
alst = list(map(int, input().split()))
ind = 0
for a in alst:
  if a % 2 == 0:
    ind += a
  else:
    ind -= a
  ind = ind % len(lst)
  lst.pop(ind)
  ind = ind % len(lst)

qlst = list(map(int, input().split()))
for q in qlst:
  print(int(lst[bl(lst, q)] == q))