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:
def get_divisor(n):
    a = [1]
    b = [n]
    for i in range(2,int(n**0.5)):
        if n%i==0:
            a.append(i)
            b.append(n//i)
    if int(n**0.5)**2==n:a.append(int(n**0.5))
    a.extend(b[::-1])
    return a

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 get_divisor(i):
            D[j]+=1
print(len(ans))
print(*ans)

Submission status: Wrong Answer

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

ball = [0] * N


if a[-1] == 1:
        ball[-1] = 1

for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        #print("i j ", i , j)
                        if (j + 1) % (i + 1) == 0:
                                tmp += a[j]
        else:
                tmp = sum(a[1:])
        #print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1

#print(ball)

print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1, N+1)[::-1]:
    ans_bit = sum(a[i::i]) % 2
    if a[i] != ans_bit:
        print("-1")
        exit()
    i -= 1

print(sum(a))
b = [index for index, v in enumerate(a) if v == 1]
if len(b) > 0:
    print(*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int,input().split()))
b_list = [0]*(n-n//2-1)+a_list[(n-n//2-1):]

for i in range(n//2):
    k = int(n//2-i-1)
    if a_list[k] != sum(b_list[k::k+1])%2:
        b_list[k] = 1

b_list = [i+1 for i,x in enumerate(b_list) if x ==1]
x = len(b_list)
print(x)
if x != 0:
    print(*b_list)

Submission status: Wrong Answer

Solution code:
def add(n):
    return n + 1

if __name__ == "__main__":
    n = int(input())
    buf = input().split()
    a = [int(s) for s in buf]
    
    boxes = [0] * n

    for i in reversed(range(n)):
        pick_boxes = boxes[i::i+1]
        pick_boxes.pop(0)
        if pick_boxes:
            if sum(pick_boxes) == a[i]:
                boxes[i] = 0
            else:
                boxes[i] = 1
        else:
            boxes[i] = a[i]

    box_name = [i for i, x in enumerate(boxes) if x == 1]
    box_name = list(map(add, box_name))
    print(len(box_name))
    if len(box_name) != 0:
        box_name = ' '.join(map(str,box_name))
        print(box_name)

Submission status: Wrong Answer

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

ball = [0] * N


if a[-1] == 1:
        ball[-1] = 1

for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        #print("i j ", i , j)
                        if (j + 1) % (i + 1) == 0:
                                tmp += a[j]
        else:
                tmp = sum(a[1:])
        print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1

#print(ball)

print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))

primes = []
pr_array = np.array(list(range(n+1)))
if sum(a)==0:
    print('0')
    exit()
primes.append(n)
pr_array[n] = 1
for i in range(n-2,-1,-1):
    num = i + 1
    # print(primes)
    if a[i]==1:
        cnt = 0
        for mul in range(int(n/num)):
            cnt += pr_array[num * mul]
        if cnt%2==0:
            primes.append(num)
            pr_array[num] = 1

print(len(primes))
print(*primes)

Submission status: Wrong Answer

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

ball = [0] * N
ans = []

for i in range(1, N+1) :
    ballCount = sum(ball[N-i::N-i+1])
    if ballCount % 2 == A[N-1] :
        pass
    else :
        ball[N - i] = 1
        ans.append(N - i + 1)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
aN = [ int(i) for i in input().split() ]
bN = [0] * N

for i in range(N, 0, -1):
    if sum(aN[i-1: :i]) % 2 != aN[i - 1]:
        bN[i-1] = 1

print(sum(bN))
if sum(bN) != 0:
    print(*[i+1 for i, b in enumerate(bN) if b == 1])

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
half=int(N/2)
ans=[-1]*N

for i in range(half, N):
    ans[i]=a[i]
for i in range(half-1, -1, -1):
    tmp=(sum(a[i::(i+1)]) + 1)%2
    ans[i]=tmp^a[i]

print(sum(ans))
for i,a in enumerate(ans):
    if a==1:
        print(i+1)

Submission status: Wrong Answer

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

ball = [0] * N
ans = []

for i in range(1, N+1) :
    ballCount = sum(ball[N-i::N-i+1])
    if ballCount % 2 == A[N-1] :
        pass
    else :
        ans.append(i)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]
r=list(map(int,input().split()))
for i in range(n):
  a.append(r[i])
b=[0 for i in range(n+1)]


for i in range((n//2+1),n+1):
  b[i]=a[i]
for i in range(n//2,0,-1):
  print("i",i)
  j=2
  b[i]=a[i]
  while(j*i<=n):
    b[i]^=b[j*i]
    j+=1

m=0
for i in range(n+1):
  m+=b[i]
print(m)
for i in range(1,n+1):
  if b[i]==1:
    print(i)

Submission status: Wrong Answer

Solution code:

import numpy as np
n = int(input())
a = np.zeros((n+1))

a_list = np.array(list(map(int, input().strip().split())))

a[1:] = a_list

b = a

for i in reversed(range(1,n+1)):
    sum_of_other_b = 0
    #print(i)
    for j in range(2,int(n/i + 1)):
        #print(i,j)
        sum_of_other_b += b[i*j]

    if (sum_of_other_b % 2) == a[i]:
        b[i] = 0
    else:
        b[i] = 1

b = b.astype(int)
b = b[1:]
#print(b)

flag = True
for i in range(n):
    if b[i] < 0:
        flag = False
        break

if flag:
    print(str(b).replace('[','').replace(']','').replace(' 0','').replace('0 ',''))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]
r=list(map(int,input().split()))
for i in range(n):
  a.append(r[i])
b=[0 for i in range(n+1)]


for i in range((n//2+1),n+1):
  b[i]=a[i]
for i in range(n//2,0,-1):

  j=2
  b[i]=a[i]
  while(j*i<=n):
    b[i]^=a[j*i]
    j+=1

m=0
for i in range(n+1):
  m+=b[i]
print(m)
for i in range(1,n+1):
  if b[i]==1:
    print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
box=[0]*N
a_list=list(map(int,input().split()))
sum=0
for i in range(N-1,-1,-1):
    for j in range(1,N):
        if j*(i+1) < N:
            if box[j*(i+1)-1]==1:
                sum+=1
        else:
            break
    if sum%2 != a_list[i]:
            box[i]=1
    sum=0
ans=[]
sum=0
for i,k in enumerate(box):
    if k==1:
        sum+=1
        ans.append(str(i+1))
print(sum)
print(" ".join(ans))

Submission status: Wrong Answer

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

ball = [0] * (N + 1)

for i in range(N, 0, -1) :
    bit = A[i - 1]
    for j in range(i, N, i) :
        bit += ball[j]
    ball[i] = bit % 2

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

from math import ceil

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
    
for i in reversed(range(0, n)):
    d = n // (i+1)
    cn = 0
    for j in range(2, d+1, i+1):
        if b[j*(i+1)] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
ee = []
for i,v in enumerate(b):
    if i == 0:
        continue
    if v == '1':
        ee.append(str(i))
print(' '.join(ee))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]
r=list(map(int,input().split()))
for i in range(n):
  a.append(r[i])
b=[0 for i in range(n+1)]


for i in range((n//2+1),n+1):
  b[i]=a[i]
for i in range(n//2,0,-1):

  j=2
  b[i]=a[i]
  while(j*i<=n):
    b[i]^=a[j*i]
    j+=1

m=0
for i in range(n):
  m+=b[i]
print(m)
for i in range(1,n+1):
  if b[i]==1:
    print(i)

Submission status: Wrong Answer

Solution code:

import numpy as np
n = int(input())
a = np.zeros((n+1))

a_list = np.array(list(map(int, input().strip().split())))

a[1:] = a_list

b = a

for i in reversed(range(1,n+1)):
    sum_of_other_b = 0
    print(i)
    for j in range(2,int(n/i + 1)):
        print(i,j)
        sum_of_other_b += b[i*j]

    if (sum_of_other_b % 2) == a[i]:
        b[i] = 0
    else:
        b[i] = 1

b = b.astype(int)
b = b[1:]
#print(b)

flag = True
for i in range(n):
    if b[i] < 0:
        flag = False
        break

if flag:
    print(str(b).replace('[','').replace(']','').replace(' 0',''))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
l = []
counter = 0
ans_list = []

n = int(input())
b_list = [0 for _ in range(n)]
l = list(map(int, input().split()))

for i in range(n,0,-1):
    index = n // i
    if index == 1: # 倍数がないとき
        b_list[i-1] = l[i-1]
    else:
        sum = 0
        for j in range(2, index+1):
            sum = sum + b_list[(i * j)-1]
        #print(l[i-1], sum)
        b_list[i-1] = max(l[i-1], (sum % 2))

    if b_list[i-1] == 1:
        counter += 1
        ans_list.append(str(i))

#print(ans_list)
print(counter)
if ans_list != []:
    print(' '.join(ans_list))

Submission status: Wrong Answer

Solution code:
N=int(input())
Arr=[int(thing) for thing in input().split(" ")]
Box=[0 for i in range(N)]

for i in range(N):
    i=N-i
    baisu=[i*j for j in range(N//i)]
    bit=sum([Box[j-1] for j in baisu])//2
    if Arr[i-1]==0:
        if bit==0:
            Box[i-1]=0
        else:
            Box[i-1]=1
    else:
        if bit==0:
            Box[i-1]=1
        else:
            Box[i-1]=0
print(sum(Box))
print(" ".join([str(i+1) for i in range(len(Box)) if Box[i]==1]))

Submission status: Wrong Answer

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

ball = [0] * (N + 1)

for i in range(N, 0, -1) :
    bit = A[i - 1]
    for j in range(i, N, i) :
        bit ^= ball[j]
    ball[i] = bit
ball.pop(0)
print(*ball)

Submission status: Wrong Answer

Solution code:
import sys
import math

def add_ball(idx):
    add_list = []
    for j in range(1, int(math.sqrt(idx))+1):
        if idx%j == 0:
            add_list.append(j)
            if j != idx//j:
                add_list.append(idx//j)
    for k in add_list:
        b_list[k] += 1

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * (n+1)
    ans_list = []
    for a, i in zip(reversed(a_list), range(n, 0, -1)):
        if a != b_list[i]%2:
            ans_list.append(i)
            add_ball(i)
    cnt = len(ans_list)
    ans_list.sort()
    if cnt > 0:
        print(' '.join(map(str, ans_list)))

Submission status: Wrong Answer

Solution code:
N=int(input())
Arr=[int(thing) for thing in input().split(" ")]
Box=[0 for i in range(N)]

for i in range(N):
    i=N-i
    baisu=[i*j for j in range(N//i)]
    bit=sum([Box[j-1] for j in baisu])//2
    if Arr[i-1]==0:
        Box[i-1]=0
    else:
        Box[i-1]=1
print(sum(Box))
print(" ".join([str(i+1) for i in range(len(Box)) if Box[i]==1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
aN = [ int(i) for i in input().split() ]
bN = [0] * N

for i in range(N, 0, -1):
    if sum(aN[N-1::N]) % 2 != aN[i - 1]:
        bN[i-1] = 1

print(sum(bN))
print(*[i+1 for i, b in enumerate(bN) if b == 1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = []
for n in range(N):
    b.append(0)

def box_sum(a):
    s = 0
    for n in range(1,a):
        s = s + b[(i+1)*(N-k)]
    return s

for k in range(N):
    c = N//N-k
    if c==1:
        b[N-1-k] = a[N-1-k]
    else:
        s = box_sum(c)
        if s%2==a[N-1-k]%2:
            b[N-1-k] = 0
        else:
            b[N-1-k] = 1
print(b.count(1))
box_num = [i for i,x in enumerate(b) if x == 1]
for d in range(b.count(1)):
    print(box_num[d]+1)

Submission status: Wrong Answer

Solution code:
l = []
counter = 0
ans_list = []

n = int(input())
b_list = [0 for _ in range(n)]
l = list(map(int, input().split()))

for i in range(n,0,-1):
    index = n // i
    if index == 1: # 倍数がないとき
        b_list[i-1] = l[i-1]
    else:
        sum = 0
        for j in range(2, index):
            sum = sum + b_list[(i * j)-1]
        #print(l[i-1], sum)
        if l[i-1] != (sum % 2):
            b_list[i-1] = max(l[i-1], (sum % 2))

    if b_list[i-1] == 1:
        counter += 1
        ans_list.append(str(i))

#print(ans_list)
print(counter)
if ans_list != []:
    print(' '.join(ans_list))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int,input().split()))
b_list = [0]*(n-n//2-1)+a_list[n//2:]

for i in range(n//2):
    if a_list[n//2-i-1] != sum(b_list[n//2-i-1::n//2-i])%2:
        b_list[n // 2 - i - 1] = 1

b_list = [i+1 for i,x in enumerate(b_list) if x ==1]
x = len(b_list)
print(x)
if x != 0:
    print(*b_list)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

from math import ceil

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
    
for i in reversed(range(0, n)):
    d = n // (i+1)
    cn = 0
    for j in range(2, d+1, i+1):
        if b[j*(i+1)] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
del b[0]
ee = []
for i,v in enumerate(b):
    if v == '1':
        ee.append(str(i+1))
print(' '.join(ee))

Submission status: Wrong Answer

Solution code:
n= int(input())
A = list(map(int, input().split()))
B = [0]*(n+1)
B_sum = [0]*(n+1)
count = 0

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

    j = 1
    while (n-i+1)*j <= n:
        B_sum[n-i] += B[(n-i)*j]
        j += 1
    if B_sum[i] % 2 != A[i-1]:
        B[i] = 1
        count += 1
print(count)
for i in range(1,n+1):
    
    if B[i]==1:
        print(str(i) + " ", end = "")

Submission status: Wrong Answer

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

ball = [0] * N

for i in range(N-1, -1, -1) :
    bit = A[i]
    for j in range(1, N) :
        if i * j >= N :
            break
        bit = bit + ball[i * j]
    ball[i] = bit % 2

print(*ball)

Submission status: Wrong Answer

Solution code:
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N
# half = math.ceil(N/2)
summ = 0
for i in reversed(range(N)):
# print(i)
    x = N//(i+1)
# print("x",x)
    if x == 1:
        b[i] = a[i]
    else:
        for j in range(x):
            # print(j)
            summ += a[(i+1)*(j+1)-1]
        summ -= a[i]
        # print("sum=",summ)
        judge=summ%2
        # print("judge",judge)
        if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
            b[i] = 0
        else:
            b[i] = 1
        summ = 0
        judge = 0
# print(b)
print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    # print(ans)
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(str(ans.pop()))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
if n==1:
    print(l[0])
    exit()
ans=[0]*(n//2)+l[n//2:n]
for i in range(n//2-1,-1,-1):
    s= sum([ans[j] for j in range((i+1)*2-1,n,i+1)])%2
    ans[i]=(l[i]+s)%2
lans=[]
for i in range(n):
    if ans[i]==1:lans.append(i+1)
print(sum(ans))
if sum(ans)>0:print(*lans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0] * N
ans = []
for i in reversed(range(1, N+1)):
    a = 0
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        a = (B[tmp-1] + a) % 2
    if (A[i-1] + a) % 2 == 1:
        ans.append(i)
    B[i-1] = a
print(len(ans))
for a in ans: print(a)

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1) :
    num = i+1
    cnt = 0
    for j in range(i,N,num) :
        cnt += A[j]
    
    if A[i] == 1 :
        if cnt % 2 == 1 :
            ans.append(i+1)
    
    elif A[i] != cnt % 2 :
        ans = -1
        break
if ans == -1 :
    print(ans)
else :
    print(len(ans))
    print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque

def prime(N):
    se = [0,0,1]+[1]*(N-2)
    n = 2
    while n ** 2 <= N:
        if se[n]:
            nn = 2*n
            while nn <= N:
                se[nn] = 0
                nn += n
        n += 1

    return [x for x in range(0,N+1) if se[x]]

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

# N = 1のときはコーナーケース！

if N == 1:
    if A[0] == 1:
        print(1)
        print(1)
    else:
        print(0)
    exit()

pr = prime(N)

deq = deque(pr)
deq.appendleft(1)

cnt = len(deq)

d = [0]*(N+1)
d[1] = -1
for p in pr:
    d[p] = -1

B = pr
while cnt < N:
    C = []
    for num in B:
        if num * 2 > N:
            break
        for p in pr:
            if num * p > N:
                break
            aaa = num * p
            if d[aaa] <= 0:
                d[aaa] = p
                deq.append(aaa)
                C.append(aaa)
                cnt += 1
    B = sorted(C)

for _ in range(N):
    n = deq.pop()
    if sum(A[n-1:N:n]) != A[n-1]:
        print(-1)
        exit()

a = sum(A)
print(a)
for _ in range(a):
    print(1)

Submission status: Wrong Answer

Solution code:
N = int(input())
aN = [ int(i) for i in input().split() ]
bN = []

for i in range(N, 0, -1):
    if sum(aN[N-1::N]) % 2 != aN[i - 1]:
        bN.append(i)

print(len(bN))
print(*bN)

Submission status: Wrong Answer

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

ball = [0] * N

for i in range(N-1, -1, -1) :
    bit = 0
    for j in range(1, N) :
        if i * j >= N :
            break
        bit = (bit + ball[i * j]) % 2
    ball[i] = bit % 2

print(*ball)

Submission status: Wrong Answer

Solution code:
N = int(input())
aN = [ int(i) for i in input().split() ]
bN = [0] * N

for i in range(N, 0, -1):
    if sum(aN[N-1::N]) % 2 != aN[i - 1]:
        bN.append(i)

print(len(bN))
print(*bN)

Submission status: Wrong Answer

Solution code:
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N
half = math.ceil(N/2)
summ = 0
for i in reversed(range(N)):
    # print(i)
    if i >= half-1:
        b[i] = a[i]
    else:
        x = N//(i+1)
    # print("x",x)
        if x == 1:
            b[i] = a[i]
        else:
            for j in range(x):
                # print(j)
                summ += a[(i+1)*(j+1)-1]
            summ -= a[i]
            # print("sum=",summ)
            judge=summ%2
            # print("judge",judge)
            if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
                b[i] = 0
            else:
                b[i] = 1
            summ = 0
            judge = 0
# print(b)
print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    # print(ans)
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(ans.pop())

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

from math import ceil

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
    
for i in reversed(range(0, n)):
    d = n // (i+1)
    cn = 0
    for j in range(2, d+1, i+1):
        if b[j] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
del b[0]
ee = []
for i,v in enumerate(b):
    if v == '1':
        ee.append(str(i+1))
print(' '.join(ee))

Submission status: Wrong Answer

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

ball = [0] * N

for i in range(N-1, -1, -1) :
    bit = A[i]
    for j in range(1, N) :
        if i * j >= N :
            break
        bit = (bit + ball[i * j]) % 2
    ball[i] = bit % 2

print(*ball)

Submission status: Wrong Answer

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

box = [-1] * N
ans = 0
for i in range(N//2, N):
    if A[i] == 1:
        box[i] = 1
        ans += 1
    else:
        box[i] = 0

for i in range(N//2, 0, -1):
    # print('A[{}]: {}'.format(i, A[i-1]))
    i_sum = sum(A[i*2-1::i])
    if A[i-1] == (i_sum % 2):
        box[i-1] = 0
    else:
        box[i-1] = 1
        ans += 1


print(ans)
if ans > 0:
    for bi, ball in enumerate(box):
        if ball == 1:
            print(bi+1, end=' ')
    print()

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(N)]
c=[]
A=0
B=0
for i in range(N):
    s=N//(i+1)
    p=1
    while p<=s:
      if b[(i+1)*p-1]==1:
        A+=1
      p+=1
    p=1
    if (A-a[N-1-i])%2==0:
      b[N-1-i]=0
    elif (A-a[N-1-i])%2==1:
      b[N-1-i]=1
    A=0
for i in range(N):
  if b[i]==1:
    B+=1
    c+=[i+1]
c=[c]
print(B)
print(*c[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
aN = [ int(i) for i in input().split() ]
bN = [0] * N

for i in range(N, 0, -1):
    if sum(aN[N-1::N]) % 2 != aN[i - 1]:
        bN[i-1] = 1

print(sum(bN))
print(*[b+1 for b in bN if b == 1])

Submission status: Wrong Answer

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

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

print(sum(b))
for i in range(n):
    if b[i] == 1:
        print(i+1,end = " ")
print()

Submission status: Wrong Answer

Solution code:
N = int(input())
aN = [ int(i) for i in input().split() ]
bN = [0] * N

for i in range(N, 0, -1):
    if sum(aN[N-1::N]) % 2 != aN[i - 1]:
        bN[i-1] = 1

print(sum(bN))
print(*[b for b in bN if b == 1])

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1) :
    num = i+1
    cnt = 0
    for j in range(i,N,i+1) :
        cnt += A[i]
    
    if A[i] == 1 :
        if cnt % 2 == 1 :
            ans.append(i+1)
    
    elif A[i] != cnt % 2 :
        ans = -1
        break
if ans == -1 :
    print(ans)
else :
    print(len(ans))
    print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

from math import ceil

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
c = ceil((n+1)/2)-1
for i in range(c, n):
    if a[i] == 1:
        b[i+1] = '1'
    else:
        b[i+1] = '0'
    
for i in reversed(range(0, c)):
    d = n // (i+1)
    cn = 0
    for j in range(2, d+1, i+1):
        if b[j] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
del b[0]
ee = []
for i,v in enumerate(b):
    if v == '1':
        ee.append(str(i+1))
print(' '.join(ee))

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1) :
    num = i+1
    cnt = 0
    for j in range(i,N,i+1) :
        cnt += A[i]
    
    if A[i] == 1 :
        if cnt % 2 == 0 :
            ans.append(i+1)
    
    elif A[i] != cnt % 2 :
        ans = -1
        break
if ans == -1 :
    print(ans)
else :
    print(len(ans))
    print(*ans, sep="\n")

Submission status: Wrong Answer

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

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    sum_chk = sum(chk[N-i-1::N-i])
    if sum_chk == a-1:
        chk[N-i-1] = 1
        continue
    elif sum_chk == a:
        continue
    else:
        print(-1)
        exit()

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1) :
    num = i+1
    cnt = 0
    for j in range(i+i+1,N,i+1) :
        cnt += A[i]
    
    if A[i] == 1 :
        if cnt % 2 == 0 :
            ans.append(i+1)
    
    elif A[i] != cnt % 2 :
        ans = -1
        break
if ans == -1 :
    print(ans)
else :
    print(len(ans))
    print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
# Setup
import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
balls = [0] * (n+1)

for i in reversed(range(1,n+1)):
    temp = i*2
    current = 0
    while temp < n:
        current += balls[temp]
        temp += i
    if current%2 == 0:
        if a[i-1] == 0:
            balls[i] = 0
        else:
            balls[i] = 1
    else:
        if a[i-1] == 1:
            balls[i] = 1
        else:
            balls[i] = 0
counter = 0
for i in range(n):
    if balls[i+1] == 1:
        counter += 1
print(counter)
for i in range(n):
    if balls[i+1] == 1:
        print(i+1)

Submission status: Wrong Answer

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

chk = [0]*N
print(N, A)

A.reverse()
for i, a in enumerate(A):
    print('i', i)
    sum_chk = sum(chk[N-i-1::N-i])
    if sum_chk == a-1:
        chk[N-i-1] = 1
        continue
    elif sum_chk == a:
        continue
    else:
        print(-1)
        exit()

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

Submission status: Wrong Answer

Solution code:
# Setup
import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
balls = [0] * (n+1)

for i in reversed(range(1,n+1)):
    temp = i*2
    current = 0
    while temp < n:
        current += balls[temp]
        temp += i
    if current%2 == 0:
        if a[i-1] == 0:
            balls[i] = 0
        else:
            balls[i] = 1
    else:
        if a[i-1] == 0:
            balls[i] = 1
        else:
            balls[i] = 0
counter = 0
for i in range(n):
    if balls[i+1] == 1:
        counter += 1
print(counter)
for i in range(n):
    if balls[i+1] == 1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
import sys

def solve(n, a):
    b = {}
    index = {}
    for i in range(n):
        r = n / (n - i)
        sum_b = 0
        if r > 1:
            for r_i in range(r):
                sum_b += 1 if (n - i) * (r_i + 1) in b else 0

        if a[n-1 - i] != sum_b % 2:
            b[a[n-1 - i]] = 1

    print len(b)
    if len(b) > 0:
        print " ".join(map(str, b.keys()))


if __name__ == '__main__':

    n = int(sys.stdin.readline().strip())
    a = map(int, sys.stdin.readline().strip().split(" "))
    solve(n, a)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [-1] * len(a)
for i in range(n - 1, -1, -1):
  b[i] = 0 if sum([a[(i + 1) * (j + 1) - 1] for j in range(n // (i + 1))]) % 2 == a[i] else 1
print(sum(b))
print(*[i + 1 for i in range(len(b)) if b[i] == 1])

Submission status: Wrong Answer

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

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

print(sum(b))
for i in range(n):
    if b[i] == 1:
        print(i+1,end = " ")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)

ans = []
for i in reversed(range(1, N + 1)):
    if sum(A[i::i]) % 2 != A[i]:
        A[i] = ~A[i]
    if A[i] == 1:
        ans.append(i)

print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(N)]
c=[]
A=0
B=0
for i in range(N):
    s=N//(i+1)
    p=1
    while p<=s:
      if b[(i+1)*p-1]==1:
        A+=1
      p+=1
    p=0
    if (A-a[N-1-i])%2==0:
      b[N-1-i]=0
    elif (A-a[N-1-i])%2==1:
      b[N-1-i]=1
    A=0
for i in range(N):
  if b[i]==1:
    B+=1
    c+=[i+1]
c=[c]
print(B)
print(*c[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]

total = 0
b = []
for i in range(N):
    if total != a[i]:
        total = total + 1
        b.append(N - i)

print(total)
for k in b:
    print(k)

Submission status: Wrong Answer

Solution code:

import numpy as np
n = int(input())
a = np.zeros((n+1))

a_list = np.array(list(map(int, input().strip().split())))

a[1:] = a_list

b = a

for i in reversed(range(1,n+1)):
    sum_of_other_b = 0
    #print(i)
    for j in range(2,int(n/i+1)):
        #print(i,j)
        sum_of_other_b += a[i*j]

    if (sum_of_other_b % 2) == a[i]:
        b[i] = 0
    else:
        b[i] = 1

b = b.astype(int)
b = b[1:]
#print(b)

flag = True
for i in range(n):
    if b[i] < 0:
        flag = False
        break

if flag:
    print(str(b).replace('[','').replace(']','').replace(' 0',''))

else:
    print(-1)

Submission status: Wrong Answer

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

box = [-1] * N
ans = 0
for i in range(N//2, N):
    if A[i] == 1:
        box[i] = 1
        ans += 1
    else:
        box[i] = 0

for i in range(N//2, 0, -1):
    # print('A[{}]: {}'.format(i, A[i-1]))
    i_sum = sum(A[i*2::i])
    if A[i-1] == (i_sum % 2):
        box[i-1] = 0
    else:
        box[i-1] = 1
        ans += 1


print(ans)
if ans > 0:
    for bi, ball in enumerate(box):
        if ball == 1:
            print(bi+1, end=' ')
    print()