Problem:


Score : 400 points

Problem Statement

There are N empty boxes arranged in a row from left to right.
The integer i is written on the i-th box from the left (1 \leq i \leq N).

For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.

We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:

For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.

Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

If a good set of choices does not exist, print -1.

If a good set of choices exists, print one such set of choices in the following format:

M
b_1 b_2 ... b_M

where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.

Sample Input 1

3
1 0 0

Sample Output 1

1
1

Consider putting a ball only in the box with 1 written on it.

There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.

There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.

There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.

Thus, the condition is satisfied, so this set of choices is good.

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

Putting nothing in the boxes can be a good set of choices.



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    B = [0] * N
    i = N
    b = 2
    while i > N / b:
        B[i-1] = A[i-1]
        i -= 1
    b = 3
    while i > 0:
        while i > N / b:
            B[i-1] = (A[i-1] + B[i*2-1]) % 2
            i -= 1
        b += 1
    C = []
    for i, b in enumerate(B):
        if b > 0:
            C.append(i+1)
    M = len(C)
    print(M)
    for c in C:
        print(c, end=' ')
    print()

main()

Submission status: Wrong Answer

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

MOD = 2  # type: int

def solve(N: int, a: "List[int]"):
    a = [0] + a
    result = [0 for i in range(N+1)]
    for i in range(N, 0, -1):
        count_baisu = 1

        sum_ = 0
        while count_baisu * i <= N:
            sum_ += result[count_baisu * i]
            count_baisu += 1

        if a[i] == 0:
            if sum_ == 0:
                result[i] = 0
            else:
                result[i] = 1
        else:
            if sum_ == 0:
                result[i] = 1
            else:
                result[i] = 0
                
    print(sum(result))
    for i in range(1, N+1):
        if result[i] == 1:
            print(i)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(a) for a in input().split()]
flag = [0] * (n + 1)
ret = []
for i in range(n, 0, -1):
    if flag[i] ^ a[i - 1] == 1:
        ret.append(i)
    j = 1
    while j * j <= i:
        if i % j == 0:
            flag[j] ^= a[i - 1]
            if j * j != i:
                flag[i // j] ^= a[i - 1]
        j += 1
print(len(ret))
for r in ret:
    print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = a[:]

for i in range(n):
    ans[i] = sum(ans[i :: i + 1]) % 2

print(sum(ans))
print(*[i + 1 for i in range(n) if ans[i]])

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
A = [0] + list(map(int, input().split()))

lst = []
for i in range(1, N + 1):
    goukei = 0
    for j in range(i, N + 1, i):
        goukei += A[j]

    amari = goukei % 2
    if amari == A[i]:
        if amari == 1:
            lst.append(i)
    else:
        print(-1)
        sys.exit(0)

print(len(lst))
if len(lst) != 0:
    print(" ".join([str(i) for i in lst]))

Submission status: Wrong Answer

Solution code:
n=int(input())
aa=list(map(int,input().split()))
aa=[-1]+aa[:]
ans=[]
for i in range((n+1)//2-1,0,-1):
    s=0
    for ii in range(i*2,n+1,i):
        s+=aa[ii]
    if aa[i]==s%2:
        aa[i]=0
    else:
        aa[i]=1
        ans.append(i)
print(len(ans))
if ans:
    print(*ans,sep="\n")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def solve(N: int, a: "List[int]"):

    b = [0]*N
    for i in range(N-1, -1, -1):
        if b[i] % MOD != a[i]:
            b[i] = 1
        if a[i] == 1:
            # print(make_divisors(i))
            for d in make_divisors(i)[:-1]:
                b[d] += 1
    # for i in range(N//2-1, -1, -1):
    #     if a[i] != b[i] % 2:
    #         b[i] += 1
    # b[0] = a[0]-b[0]
    # print(b)

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = copy.deepcopy(A)

if max(A) > 1:
	print("-1")
else:
	for i in range(N // 2, 0):
		total = 0
		for j in range(2 * i, N + 1, i):
			total += A[j]
		if total % A[i] != 0:
			B[i] = 1
			
	print(sum(B))
	for i in range(len(B)):
		if B[i] == 1:
			print(i, end = " ")

Submission status: Wrong Answer

Solution code:
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    a_list = li()
    box_list = [0] * n
    div = 1
    while n // (div + 1) - 1 >= 0:
        for i in range(n // div - 1, n // (div + 1) - 1, -1):
            value = a_list[i]
            index = i * 2
            while index < n:
                value = value ^ box_list[index]
                index = index + i
            box_list[i] = value
        div = div + 1
    box_sum = sum(box_list)
    box_list[0] = (box_sum % 2) ^ a_list[0]
    print(box_sum + box_list[0])
    for index, box in enumerate(box_list):
        if box == 1:
            print(index + 1)

# n // 2 + 1 -- n まではaの通りにボールを入れる
# n // 3 + 1 -- n // 2 まではaと２倍した場所の箱を見てボールを入れる
#

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n = onem()

a = l()
k = 0
for i in range(n):
	if a[-(i+1)] == 1:
		k = n - i
		break
if k == 0:
	print(0)
	exit()

m = [0 for i in range(k+1)]
al = 0
for i in range(k,0,-1):
	co = 0
	if k // i < 2:
		m[i] = a[i-1]
		al += a[i-1]
	else:
		if i != 1:
			print(k // i)
			for j in range(1,k // i):
				co += m[i * (j+1)]
				co %= 2
			m[i] = (co ^ a[i-1])
			al += m[i]
		else:
			al %= 2
			m[0] = (al ^ m[1])
mmm = m[1:]
print(len(mmm))
print(jo(mmm))

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = list(map(int, input().split()))

for i in range(1, N+1):

    j = i
    sum_num = 0
    while j <= N:
        a = a_list[j-1]
        sum_num += a
        if i == 1:
            j += 1
        else:
            j *= i

    if sum_num % 2 == a_list[i-1]:
        continue
    else:
        a_list[i-1] += 1

ans = sum(a_list)
print(ans)

for i in range(1, N+1):
    if a_list[i-1] != 0:
        print(i)

Submission status: Wrong Answer

Solution code:
def fact(n):
    s=set()
    x=1
    while(x*x<=n):
        s.add(x)
        s.add(n//x)
        x+=1
    return s
n=int(input())
l=list(map(int,input().split()))
arr=[i+1 for i in range(n) if l[i]==1]
dic={}
for i in range(len(arr)):
    ans=fact(arr[i])
    for i in ans:
        dic[i]=dic.get(i,0)+1
m=0
ans=[]
for i in dic:
    if(dic[i]!=0 and dic[i]%2==1):
        m+=1
        ans.append(l[i-1])
print(m)
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a_list=list(map(int,input().split()))
a_list=[0]+a_list
ans=[0]*(n+1)
count=0
for i in range(n,0,-1):
    temp=0
    c=n//i
    for j in range(2,c+1):
        temp+=ans[i*j]
    if temp%2==a_list[i]:
        ans[i]=0
    else:
        ans[i]=1
        count+=1
print(count)
for i in range(n+1):
    if ans[i]==1:
        print(i,end='')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

if A[0] == 0:
    print(0)
else:
    if N == 0:
        print(-1)
    else:
        print("1\n1")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

n=I()
a=[0]+LI()
b=[0]*(n+1)
c=[0]*(n+1)
for i in range(n,0,-1):
    if c[i]!=a[i]:
        b[i]=1-b[i]
        for j in range(2,int(i**0.5+1+10**-9)):
            if i%j==0:
                b[i]=1-b[i]
                b[i//j]=1-b[i//j]

s=sum(b)
if s%2!=a[1]:
    b[1]=1
print(sum(b))
for i in range(1,n+1):
    if b[i]==1:
        print(i,end=' ')
'''
print(a)
print(b)
print(c)
'''

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if a[0] == 0:
        print(0)
    else:
        print(1)
        print(1)


main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = ['null']
a += list(map(int,input().split()))
b = ['null'] + [0 for _ in range(n)]
for i in range(n):
  k = n - i
  d = n // k
  xor = 0
  for di in range(1,d+1):
    xor ^= b[di * k]
  b[k] = a[k] ^ xor
c = []
csum = 0
for i in range(n):
  if b[i] == 1:
    c.append(str(i))
    csum += 1
print(csum)
print(' '.join(c))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
import math
mod = 10**9 + 7
def I(): return int(input())
def II(): return map(int, input().split())
def L(): return list(map(int, input().split()))
def TWO(M):
  L=[0]*M
  R=[0]*M
  for i in range(M):
    L[i],R[i] = II()
  return L, R

N = I()
a = L()
ans = [-1]*N

for i in range(N)[::-1]:
  temp = N//(i+1)
  x = []
  for j in range(2,temp):
    x.append(ans[i*j])
  ans[i] = a[i]-sum(x)%2

print(ans.count(1))
for i in range(N):
  if ans[i]==1:
    print(i+1)

Submission status: Wrong Answer

Solution code:
import math

n=int(input())
alist=list(map(int, input().split())) 
blist=[]
for i in range(n):
    blist.append([])

for i in range(n):
    ima=n-i-1
    kosu=math.floor(n/(ima+1))
    nanko=0
    #print(ima, kosu)
    for j in range(kosu-1):
        nima=(kosu-j-1)*(ima+1)
        if blist[nima][0]==1:
            nanko+=1
    nanko=nanko%2
    if alist[ima]==nanko:
        blist[ima]=[0]
    else:
        blist[ima]=[1]

#print(blist)
kotaelist=[]
for bl in range(n):
    if blist[bl]==[1]:
        kotaelist.append(bl+1)

print(len(kotaelist))
for s in kotaelist:
    print(s, end =" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

# memo[0]: 1の箱
# memo[N]: N+1の箱
memo = [0] * N
answer = [0] * N
for i in range(N - 1, -1, -1):
    # print(i, a[i], memo[i])
    answer[i] = (a[i] + memo[i]) % 2
    if answer[i] == 1:
        for divisor in make_divisors(i+1):
            memo[divisor - 1] += 1

print(sum(answer))
# print(answer)
for i in range(N):
    if answer[i] == 1:
        print(i+1, end='')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

ans = [0]*N
for i in range(N-1,-1,-1):
    a = 0
    for j in range(2,N//(i+1)+1):
        a += A[j*(i+1)-1]
    if a%2!=A[i]:
        ans[i] = 1

print(sum(ans))
ans = [str(i+1) for i in range(N) if ans[i]==1]

print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
Bs = [-1] * N
for i in reversed(range(N)):
  a = As[i]
  r = 0
  for j in range(2,N):
    j2 = j*(i+1)-1
    if j2 >= N:
      break
    r += Bs[j2]
  b = (r+a)%2
  #print(i, a, r, b)
  Bs[i] = b
#print(Bs)
Cs = []
for i in range(N):
  if Bs[i] == 1:
    Cs.append(str(Bs[i]+1))
print(len(Cs))
print(" ".join(Cs))

Submission status: Wrong Answer

Solution code:
N = int(input())
in_list = [int(i) for i in input().split(' ')]
out_list = []
flag = 0
for i in range(1,len(in_list)+1):
    count = 0
    div_list = in_list[::i]
    count += sum(div_list)
    if count==in_list[i-1]:
        if count!=0:
            out_list.append(count)
    else :
        flag = 1
        break
if flag==1:
    print(-1)
else:
    print(len(out_list))
    for i in out_list:
        try:
            print(*i)
        except:
            break

Submission status: Wrong Answer

Solution code:
import math

n = int(input())

ans = [0] * n

def yakusuu(num):
    ret = []    
    for i in range(math.ceil(math.sqrt(num))):
        if i != 0 and num % i == 0:
            ret.append(i)
    ret.append(num)
    return ret

an = list(map(int, input().split()))
for i in range(n):
    a = an[i]
    if a == 1:
        for divisor in yakusuu(a):
            ans[divisor-1] = ans [divisor-1] + 1


ans = list(map(lambda x: x%2,ans))
print("{}".format(ans.count(1)))
for i in range(n):
    if ans[i] == 1:
        print("{}".format(i+1))

Submission status: Wrong Answer

Solution code:
N = int(input())
a_s = [int(n) for n in input().split()]

boxes = [0] * N
for i, a in enumerate(reversed(a_s)):
    i = N - i
    if a != sum(boxes[i - 1::i]) % 2:
        boxes[i-1] = 1

print(boxes.count(1))
for b in boxes:
    if b == 1:
        print(b)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if a[0] == 0:
        print(0)
    elif n == 1:
        print(1)
        print(1)
    else:
        print(1)
        l = [0] * (n - 1)
        print(1, *l)


main()

Submission status: Wrong Answer

Solution code:
def fact(n):
    s=set()
    x=1
    while(x*x<=n):
        s.add(x)
        s.add(n//x)
        x+=1
    return s
n=int(input())
l=list(map(int,input().split()))
arr=[i+1 for i in range(n) if l[i]==1]
dic={}
for i in range(1,n+1):
    dic[i]=0
for i in range(len(arr)):
    ans=fact(arr[i])
    for i in ans:
        dic[i]+=1
m=0
ans=[]
for i in dic:
    if(dic[i]!=0 and dic[i]%2==1):
        m+=1
        ans.append(l[i-1])
print(m)
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

isImpossible = False
b = [0] * N
for i in range(N-1, -1, -1):
    if i + (i+1) >= N:
        b[i] = a[i]
        continue
    s = 0
    k = i + (i+1)
    while k < N:
        s += b[i]
        k += (i+1)

    if s % 2 == a[i]:
        b[i] = 0
    else:
        b[i] = 1

#print(a)
#print(b)
if isImpossible:
    print(-1)
else:
    print(b.count(1))
    for i, bi in enumerate(b):
        if bi == 1:
            print(i+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = [0] + list(map(int,input().split()))

m = 0
# あとで先頭削除
b_list = [0 for _ in range(N+1)]

for i in range(N,0,-1):
    tmp = 0
    for j in range(i+i, N+1, i):
        tmp += b_list[j]
    
    # これまでの結果（右側）とあまりが一致してない時は1にする
    if not tmp%2 == a_list[i]:
        b_list[i] = 1
        m += 1

print(m)
print(" ".join(map(str,b_list[1:])))

Submission status: Wrong Answer

Solution code:
n = int(input())
a=list(map(int, input().split()))
ans = a[:]
for i in range(n)[::-1]:
  if i+1 > n//2:
    continue
  x = a[2*(i+1)-1]
  if a[i] == x:
    ans[i] = 0
  else:
    ans[i] = 1
m = sum(ans)
aa = []
for i in range(n):
  if ans[i]:
    aa.append(i+1)
print(m)
print(" ".join(tuple(map(str,aa))))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0]
for x in input().split():
	a.append(int(x))
x = [0] * (n + 1)

for i in range(n, 0, -1):
	x[i] = a[i]
	for j in range(2 * i, n + 1, i):
		x[i] -= x[j]
		x[i] %= 2
		x[i] += 2
		x[i] %= 2
m = 0
for i in range(1, n):
	if x[i] == 1:
		m += 1
print(m)
for i in range(1, n):
	if x[i] == 1:
		print(x[i], end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int,input().split())
D = [0]*(N+1)
ans = []
for i in range(N,0,-1):
    if D[i]%2 != A[i-1]:
        ans.append(i)
        for j in range(1,int(i**0.5)):
            if i%j==0:
                D[j] += 1
                D[i//j] += 1
        if int(i**0.5)**2 == i:D[int(i**0.5)]+=1
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = copy.deepcopy(A)

for i in range(N // 2, 0):
	total = 0
	for j in range(2 * i, N + 1, i):
		total += A[j]
	if total % A[i] != 0:
		B[i] = A[i]
		
print(sum(B))
for i in range(len(B)):
	if B[i] == 1:
		print(i, end = " ")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n

for i in range(n,0,-1):
    m=n//i
    total=0
    for j in range(1,m+1):
        total+=a[i*j-1]
    b[i-1]=total%2
ans=sum(b)
print(ans)
l=[]
for i in range(n):
    if b[i]==1:
        l.append(i+1)
print(*l)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def d(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


def main():
    N = int(input())
    # A = [
    #     int(input())
    #     for _ in range(N)
    # ]
    A = [int(a) for a in input().split()]

    res_c = 0
    res1 = []
    bucket = defaultdict(lambda: 0)
    for i in reversed(range(N)):
        k = i + 1
        if k * 2 >= N:
            if A[i] == 1:
                res_c += 1
                res1.append(k)
                for di in d(k):
                    bucket[di] = 1 + bucket[di]
            continue
        if bucket[k] % 2 == A[i]:
            pass
        else:
            res_c += 1
            res1.append(k)
            if k == 1:
                break
            for di in d(k):
                bucket[di] = 1 + bucket[di]
    print(res_c)
    print(*res1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  ans+=a[i]
print(ans)
if ans>0:
  ans=""
  p=1
  for i in range(n):
    if a[i]==1:
      if p==1:
        ans+=str(i+1)
        p=0
      else:
        ans+=" "+str(i+1)
  print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [None] + list(map(int, input().split()))

balls = [None] + ([0] * N)


def ball_in(i):
    k = 2
    n = 0
    while k * i <= N:
        n += balls[k * i]
        k += 1
    return 0 if n % 2 == A[i] else 1

for i in range(N - 1, 0, -1):
    balls[i] = ball_in(i)

M = 0
B = []
for i, b in enumerate(balls[1:]):
    if b == 1:
        M += 1
        B.append(str(i + 1))

print(M)
print(" ".join(B))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

isImpossible = False
b = [0] * N
for i in range(N-1, -1, -1):
    if i + (i+1) >= N:
        b[i] = a[i]
        continue
    s = 0
    k = i + (i+1)
    while k < N:
        s += b[i]
        k += (i+1)

    if s % 2 == a[i]:
        b[i] = 0
    else:
        b[i] = 1

#print(a)
#print(b)
if isImpossible:
    print(-1)
else:
    print(b.count(1))
    for i, bi in enumerate(b):
        if bi == 1:
            print(bi)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def solve(N: int, a: "List[int]"):

    b = [0]*N
    for i in range(N-1, -1, -1):
        b[i] = a[i]
        if a[i] > 0:
            # print(make_divisors(i))
            for d in make_divisors(i)[:-1]:
                b[d] += 1
    # for i in range(N//2-1, -1, -1):
    #     if a[i] != b[i] % 2:
    #         b[i] += 1
    # b[0] = a[0]-b[0]
    # print(b)

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))
Bs = [0] * N

for i in range(N - 1, -1, -1):
    if i >= N // 2:
        Bs[i] = As[i]
    else:
        Bs[i] = As[i] - sum(Bs[2 * i + 1::i + 1]) % 2

if -1 in set(Bs):
    print(-1)
else:
    M = sum(Bs)
    print(M)
    if M != 0:
        print(" ".join(str(i+1) for i, b in enumerate(Bs) if b == 1))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [None]*N

for n in range(N, 0, -1):
    B[n-1] = A[n-1]
    k=n*2
    while k<N:
        B[n-1] ^= B[k-1]
        k += n

M = sum(B)
print(M)
if M>0:
    print(' '.join( [str(i+1) for i,b in enumerate(B) if b==1] ))

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
Bs = [-1] * N
for i in reversed(range(N)):
  a = As[i]
  r = 0
  for j in range(2,N):
    j2 = j*(i+1)-1
    if j2 >= N:
      break
    r += Bs[j2]
  b = (r+a)%2
  #print(i, a, r, b)
  Bs[i] = b
#print(Bs)
Cs = []
for i in range(N):
  if Bs[i] == 1:
    Cs.append(str(Bs[i]))
print(len(Cs))
print(" ".join(Cs))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
box = {}
ans = ""
count = 0
for i in range(N):
    box[i+1] = 0

for i in range(N, 0, -1):
    a = 0
    for j in range(N//i):
        a += box[(j+1)*i]
    if a % 2 != A[i-1]:
        box[i] = 1
    
for k, v in box.items():
    if v == 1:
        count += 1
        ans += str(k) + " "
print(count)
if ans:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = [None] * n

for i in range(n):
    ans[i] = sum(a[i :: i + 1]) % 2

print(sum(ans))
print(*[i + 1 for i in range(n) if ans[i]])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
B = [0] * N
for i in range(N - 1, -1, -1):
  ai = A[i]
  for j in range(i, N, i + 1):
    ai ^= B[j]
  B[i] = ai
print(sum(B))
if sum(B):
  print(' '.join([str(A[i]) for i in range(N) if B[i]]))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
import math
mod = 10**9 + 7
def I(): return int(input())
def II(): return map(int, input().split())
def L(): return list(map(int, input().split()))
def TWO(M):
  L=[0]*M
  R=[0]*M
  for i in range(M):
    L[i],R[i] = II()
  return L, R

N = I()
a = L()
ans = [-1]*N

for i in range(N)[::-1]:
  temp = N//(i+1)
  x = []
  for j in range(temp-1):
    x.append(i*j)
  ans[i] = a[i]-sum(x)

print(ans.count(1))
for i in range(N):
  if a[i]==1:
    print(i+1)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
L=A[::]
for i in range(N//2,0,-1):
    x=N//i
    s=sum([L[i*(k-1)] for k in range(1,x+1)])%2
    if L[i-1]!=s: L[i-1]=s
ans=""
for c in L:
    ans+=str(c)+" "
print(ans[:-1])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n

for i in range(n,0,-1):
    m=n//i
    total=0
    for j in range(1,m+1):
        total+=a[i*j-1]
    b[i-1]=total%2
ans=sum(b)
print(ans)
print(*b)

Submission status: Wrong Answer

Solution code:
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    B = []
    b = 2
    i = N
    while i > 0:
        while i > N / b:
            if A[i-1]:
                B.append(i)
            i -= 1
        b += 1
    M = len(B)
    print(M)
    for b in B:
        print(b, end=' ')
    print()

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int,input().split())
C = [0]*(N+1)
D = [0]*(N+1)
ans = []
for i in range(N,0,-1):
    if D[i]%2 != A[i-1]:
        C[i]=1
        ans.append(i)
        for j in range(1,int(i**0.5)):
            if i%j==0:D[j] += 1
        if int(i**0.5)**2 == i:D[int(i**0.5)]+=1
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

def divisor(N, B):
    i = 1
    d = []
    while i ** 2 <= N:
        if N % i == 0:
            B[i-1] = (B[i-1] + 1) % 2
            B[N // i - 1] = (B[N//i - 1] + 1) % 2 
        i += 1
    return 0


def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [0] * N
    ans = []
    M = 0

    for i in reversed(range(N)):
        if B[i] != A[i]:
            divisor(i+1, B)
            M += 1
            ans.append(i+1)

    print(M)
    print(" ".join(map(str, ans)))

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n = int(input())
    a = [0] + [int(x) for x in input().split()]
    b = [0] * (n + 1)

    for i in range(n, 0, -1):
        tot = 0
        for j in range(2 * i, n, i):
            tot += b[j]
        tot %= 2
        b[i] = tot if a[i] == 0 else 1 - tot

    for i in range(1, n + 1):
        tot = 0
        for j in range(i, n + 1, i):
            tot += b[j]
        if tot % 2 != a[i]:
            print(-1)
            return

    res = []
    for i in range(1, n + 1):
        if b[i]:
            res.append(i)

    print(len(res))
    print(*res)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
print(-1)

Submission status: Wrong Answer

Solution code:
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
a_list = [int(elem) for elem in fin().split()]


inv_a_list = a_list[::-1]

inv_ball_in_box = []
ball_idx = []
for i, each_a in enumerate(inv_a_list):
    if each_a == 1:
        inv_ball_in_box.append(1)
        ball_idx.append(str(N-i))
    else:
        inv_ball_in_box.append(0)

print(sum(inv_ball_in_box))

if len(ball_idx) > 0:
    print(' '.join(ball_idx))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + list(map(int, input().split()))

B = [0] * (N + 1)

for i in reversed(range(1, N + 1)):
    tmp = 0
    for j in range(i, N + 1, i):
        tmp += B[j]

    if tmp % 2 != A[i]:
        B[i] = 1

for i in range(1, N + 1):
    tmp = 0
    for j in range(i, N + 1, i):
        tmp += B[j]
    if A[i] != tmp:
        print(i)
        print(-1)
        exit()

print(sum(B))
ans = []
for i, b in enumerate(B):
    if b == 1:
        ans.append(i)
if len(ans) > 0:
    print(*ans, sep=' ')