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:
N=int(input())
A=["*"]+list(map(int,input().split()))
B=["*"]+list([0]*N)

for k in range(N,0,-1):
    p=0
    for i in range(k,N+1,k):
        p^=B[i]
    B[k]=p

C=[k for k in range(1,N+1) if B[k]]
print(len(C))
if len(C)!=0:
    print(" ".join(map(str,C)))

Submission status: Wrong Answer

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

for k in range(N,0,-1):
    p=0
    for i in range(k,N+1,k):
        p^=A[i]
    B[k]=p

C=[k for k in range(1,N+1) if B[k]]
print(len(C))
if len(C)!=0:
    print(" ".join(map(str,C)))

Submission status: Wrong Answer

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

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

C=[k for k in range(1,N+1) if B[k]]
print(len(C))
if len(C)!=0:
    print(" ".join(map(str,C)))

Submission status: Wrong Answer

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

for i,x in enumerate(reversed(A)):
	if not x == sum(b[N-i-1:N-i])%2:
		b[N-1-i] = 1

for i,x in enumerate(b):
	if x:
		r.append(i+1)

print(len(r))
print(' '.join(map(str, r)))

Submission status: Wrong Answer

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

for i,x in enumerate(reversed(A)):
	if not x == sum(b[N-i-1:N-i])%2:
		b[N-1-i] = 1

print(sum(b))
for i,x in enumerate(b):
	if x:
		print(i+1)

Submission status: Wrong Answer

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

for i,x in enumerate(reversed(A)):
	if not x == sum(b[N-i-1:N-i]):
		b[N-1-i] = 1

print(sum(b))
for i,x in enumerate(b):
	if x:
		print(i+1)

Submission status: Wrong Answer

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

for i,x in enumerate(reversed(A)):
	if not x == sum(b[::N-i]):
		b[N-1-i] = 1

print(sum(b))
for i,x in enumerate(b):
	if x:
		print(i+1)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[]
for i in range(N):
  k=N-i 
  c=0
  for i in range(k,N+1,k):
    c+=A[i]
    c%=2
  if c!=(c-A[k])%2:
    B.append(k)
    
print(len(B))
for i in range(len(B)):
  print(B[-(i+1)])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[]
for i in range(N):
  k=N-i 
  c=0
  for i in range(k,N+1,k):
    c+=A[i]
    c%=2
  if A[k]!=(c-A[k])%2:
    B=[k]+B
print(len(B))
for i in B:
  print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[]
for i in range(N):
  k=N-i 
  c=0
  for i in range(k,N+1,k):
    c+=A[i]
    c%=2
  if A[k]!=(c-A[k])%2:
    B.append(k)
print(len(B))
for i in B:
  print(i)

Submission status: Wrong Answer

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

c = [0] * (n+1)
d = []

for i in reversed(range(1, n-1)):
    s = sum(c[::i])
    if s % 2 != a[i]:
        c[i] += 1
        d.append(str(i))

print(sum(c))
if sum(c) > 0:
    print(" ".join(d))

Submission status: Wrong Answer

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

if sum(a) % 2 != a[0]:
  print(-1)
else:
  for i in range(2,N+1):
    sum_a = 0
    multiple = i
    while multiple <= N:
      sum_a += a[multiple - 1]
      multiple = multiple * i
    if sum_a % 2 != a[i -1]:
      print(-1)
      ok_flag = 0
      break
    else:
      ok_flag = 1
if ok_flag == 1:
  print(sum(a))
  if sum(a) !=0:
    ans_list = []
    for i in range(N):
      if a[i] == 1:
        ans_list.append(i+1)
    print(' '.join(map(str,ans_list)))

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N = int(input())
    A = list(map(int,input().split()))

    flag = True
    ans = []
    for i in range(1,N+1):
        tmp1 = A[i-1]
        tmp2 = 0
        for j in range(i,N+1,i):
            tmp2 += A[j-1]

        if tmp2%2==tmp1:
            if tmp1==1:
                ans.append(i)
            continue
        flag = False
        break

    if flag:
        print(sum(A))
        if ans:
            print('\n'.join(map(str,ans)))
    else:
        print(-1)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
temp = [0] * N
for n in reversed(range(1,N+1)):
    if A[n-1] + temp[n - 1] == 0:
        continue
    i = 1
    temp[n - 1] += 1
    while i * i <= n:
        if not n % i:
            temp[i - 1] += 1
            temp[n // i - 1] += 1
        i += 1

res = list(i+1 for i, _ in enumerate(temp) if temp[i])
print(len(res))
print(*res)

Submission status: Wrong Answer

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

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

ans = []
for i in range(N):
  if b[i] == 1:
    ans.append(i+1)
if ans != []:
  print(len(ans))
  print(*ans)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
def divisors(n):
    lower, upper = [], []
    i = 1
    while i * i < n:
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)
        i += 1
    return lower + upper[::-1]


N = int(input())
A = [int(_) for _ in input().split()]

ans = []
for i in range(N)[::-1]:
    if A[i] % 2 == 1:
        ans.append(i+1)
        for j in divisors(i+1)[:-1]:
            A[j-1] += 1

print(len(ans))
if ans:
    print(" ".join([str(_) for _ in ans]))

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*(n+1)
for i in range(1,n+1)[::-1]:
 b[i]+=(sum(b[j] for j in range(i,n+1,i))+a[i-1])%2
print(sum(b))
print(*b[1:])

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*(n+1)
for i in range(1,n+1)[::-1]:
 b[i]+=sum(b[j] for j in range(i,n+1,i))%2+a[i-1]
print(sum(b))
print(*b[1:])

Submission status: Wrong Answer

Solution code:
from sys import exit
from collections import defaultdict as dd
n = int(input())
A = list(map(int, input().split()))

dic = dd(int)
for i, a in enumerate(A):
    dic[i+1] = a

baisu = dd(set)
for num in range(1, n+1):
    for i in range(1, n+1):
        if num * i > n:
            break
        baisu[num * i].add(num)
#print(baisu)

box = dd(int)

#dic -> baisu -> box
for num in range(n, 0, -1):
    kosu = dic[num]
    for yakusu in list(baisu[num]):
        if dic[yakusu] < kosu:
            print(-1)
            exit()
        else:
            dic[yakusu] -= kosu
        box[num] += kosu

ans = []
for i in range(1, n+1):
    if box[i] >= 1:
        ans.append(i)
print(sum([i > 0 for i in ans]))
print(*ans, sep=" ")

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

ans = [-1]*N
for i in range(N-1, -1, -1):
    a = As[i]
    if ans[i]!=-1:
        if ans[i]!=a:
            break
        continue
    ans[i] = a
    idx = i+1
    lis = make_divisors(idx)
    for l in lis[::-1]:
        nx = As[l-1]
        v = 1 if a!=nx else 0
        if ans[l-1]==-1:
            ans[l-1]= v
        elif ans[l-1]!=v:
            print(-1)
            exit(0)
        a = v
print(sum(ans))
if sum(ans):
    print(*[i+1 for i, x in enumerate(ans) if x!=0])

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

ans = [-1]*N
for i in range(N-1, -1, -1):
    a = As[i]
    if ans[i]!=-1:
        if ans[i]!=a:
            break
        continue
    ans[i] = a
    idx = i+1
    lis = make_divisors(idx)
    for l in lis[::-1]:
        nx = As[l-1]
        v = 1 if a!=nx else 0
        if ans[l-1]==-1:
            ans[l-1]= v
        elif ans[l-1]!=v:
            print(-1)
            exit(0)
print(sum(ans))
if sum(ans):
    print(*[i+1 for i, x in enumerate(ans) if x!=0])

Submission status: Wrong Answer

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

box = [-1] * (N + 1)
ball_in_list = []
# 箱について
for i in range(N, 0, -1):
    cnt = 0
    # i, 2i, 3i, ...
    for j in range(i * (N // i), i - 1, -i):

        # 確定済み
        if box[j] == 0:
            continue
        elif box[j] == 1:
            cnt += 1

        # 未確定
        elif box[j] == -1:
            # ボールを入れる
            if cnt < a[i - 1]:
                box[j] = 1
                cnt += 1
                ball_in_list.append(j)
            # ボールを入れない
            elif cnt >= a[i - 1]:
                box[j] = 0
    if cnt != a[i - 1]:
        print(-1)
        exit()

print(len(ball_in_list))
print(*ball_in_list)

Submission status: Wrong Answer

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

ans = [0]*n

for i in range(n)[::-1]:
  if i >= n//2:
    ans[i] = A[i]
  else:
    tmp = 0
    j = i+1
    while j<=n:
      tmp += A[j-1]
      j += i+1
    if A[i] == 1:
      if tmp % 2 == 1:
        ans[i] = A[i]              
    else:      
      if tmp % 2 == 1:
        ans[i] = 1
    
print(sum(ans))
print(*[i+1 for i in range(n) if ans[i] == 1])

Submission status: Wrong Answer

Solution code:
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    p2 = [0]*(n+1)
    for i in range(n,0,-1):
        sm = 0
        for j in range(i,n,i):
            sm += p2[j]
        p2[i] = (a[i-1]-sm)%2

    sm = sum(p2)
    print(sm)
    ans = []
    for i,pi in enumerate(p2):
        if pi:
            ans.append(str(i))

    print(" ".join(ans))
    return None

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

y = [0] * (N + 1)
for i in range(1, N + 1):
    if y[i] % 2 != X[i - 1]:
        for j in range(i, N + 1, i):
            y[j] += 1

if all(X[i] == y[i + 1] % 2 for i in range(N)):
    print(*y[1:], sep="\n")
else:
    print(-1)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    k, cnt = 0, 0
    while True:
        if k+i >= n:
            break
        if list_N[k+i-1] == 1:
            cnt += 1
        k += i
    list_N[i-1] = (list_A[i-1]+cnt) % 2

ans = []
for i in range(n):
    if list_N[i] == 1:
        ans.append(i+1)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=n
for i in range(n):
    for j in range(i+1,n,i+1):
        if a[i]!=a[j]:
            if a[i]==0:
                print(-1)
                exit()
            else:
                m=min(j-1,m)
for i in range(n)[::-1]:
    if a[i]==1:
        s=i+1
        print(s)
        print(*a[:s])
        break
else:
    s=0
    print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = tuple(map(int, input().split()))
b = [-1] * N
for i in range(N//2, N):
    b[i] = 1 if a[i] == 1 else 0
for j in range(N//2-1, -1, -1):
    acc = sum([b[i] for i in range(j+2, N, j+1)])
    if a[j] == 1 and acc % 2 == 0:
        b[j] = 1
    elif a[j] == 0 and acc % 2 != 0:
        b[j] = 1
    elif a[j] == 0 and acc % 2 == 0:
        b[j] = 0
    elif a[j] == 1 and acc % 2 != 0:
        b[j] = 0
if -1 in b:
    print(-1)
    exit()
ans = len([i for i in b if i == 1])
print(ans)
if ans == 0:
    exit()
print(*[j+1 for j, v in enumerate(b) if v == 1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = tuple(map(int, input().split()))
b = [-1] * N
for i in range(N//2, N):
    b[i] = 1 if a[i] == 1 else 0
for j in range(N//2-1, -1, -1):
    acc = sum(b[j+2:N:j+1])
    if a[j] == 1 and acc % 2 == 0:
        b[j] = 1
    elif a[j] == 0 and acc % 2 != 0:
        b[j] = 1
    elif a[j] == 0 and acc % 2 == 0:
        b[j] = 0
    elif a[j] == 1 and acc % 2 != 0:
        b[j] = 0
if -1 in b:
    print(-1)
    exit()
ans = len([i for i in b if i == 1])
print(ans)
if ans == 0:
    exit()
print(*[j+1 for j, v in enumerate(b) if v == 1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = tuple(map(int, input().split()))
b = [-1] * N
for i in range(N//2, N):
    b[i] = 1 if a[i] == 1 else 0
for j in range(N//2-1, -1, -1):
    acc = sum(b[j+2:N:j+1])
    if a[j] == 1 and acc % 2 == 0:
        b[j] = 1
    elif a[j] == 0 and acc % 2 != 0:
        b[j] = 1
    elif a[j] == 0 and acc % 2 == 0:
        b[j] = 0
    elif a[j] == 1 and acc % 2 != 0:
        b[j] = 0
ans = len([i for i in b if i == 1])
print(ans)
if ans == 0:
    exit()
print(*[j+1 for j, v in enumerate(b) if v == 1])

Submission status: Wrong Answer

Solution code:
N = int(input())
Ali = list(map(int,input().split()))
bli = [0]*(N+1)
M = 0

for z in range(N):
  i = N-z
  #iの倍数の箱の和%2がAliと同じか調べる
  sb = 0
  for j in range(i*2,N+1,i):
    sb += bli[j]
  if sb%2 != Ali[i-1]:
    bli[i] = 1
    M += 1
    
print(M)

cnt = 0
for i in range(N+1):
  if bli[i] == 1:
    cnt += 1
    if cnt == M:
      print(1)
    else:
      print(1,end=" ")

Submission status: Wrong Answer

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = [0] + list(map(int, input().split()))
    for i in range(n, 0, -1):
        k = 1
        flag = 0
        while i*k < n:
            flag ^= a[i*k]
            k += 1
        if flag != a[i]:
            a[i] ^= 1
    ans = [i for i in range(n+1) if a[i] == 1]
    if ans == []:
        print(0)
    else:
        print(len(ans))
        print(*ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]+list(map(int,input().split()))
d=[[] for _ in range(n+1)]
p=[0]*(n+1)
for i in range(1,n+1):
  for j in range(i,n+1,i):
    d[j]+=[i]
for i in range(n,0,-1):
  if a[i]!=p[i]:
    if p[i]:p[i]=0
    else:
      for j in d[i]:
        p[j]=1-p[j]
  else:p[i]=0
ans=[]
for i in range(n+1):
  if p[i]:ans+=[i]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]+list(map(int,input().split()))
d=[[] for _ in range(n+1)]
p=[0]*(n+1)
for i in range(1,n+1):
  for j in range(i,n+1,i):
    d[j]+=[i]
for i in range(n,-1,-1):
  if a[i]!=p[i]:
    for j in d[i]:
      p[j]+=1
      p[j]%=2
ans=[]
for i in range(n+1):
  if p[i]:ans+=[i]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
d=[[] for _ in range(n+1)]
p=[0]*(n+1)
for i in range(1,n+1):
  for j in range(i,n+1,i):
    d[j]+=[i]
for i in range(n-1,-1,-1):
  if a[i]!=p[i]:
    for j in d[i+1]:
      p[j]+=1
      p[j]%=2
ans=[]
for i in range(n+1):
  if p[i]:ans+=[i]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = []
c = [0 for _ in range(N+1)]
for i in range(N,0,-1):
    cnt = 0
    for j in range(2*i,N,i):
        if c[j] == 1:
            cnt +=1
    if (cnt%2==1 and a[i] == 0) or (cnt%2==0 and a[i] == 1):
        b.append(i)
        c[i] = 1
print(len(b))
print(*b)

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = []
for i in range(N,0,-1):
    cnt = 0
    for j in range(2*i,N,i):
        if a[j] == 1:
            cnt +=1
    if (cnt%2==1 and a[i] == 0) or (cnt%2==0 and a[i] == 1):
        b.append(i)
print(len(b))
print(*b)

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)
    return divisors

B = [0]*N
for i in range(N):
    X = N-i
    P = B[X-1]
    Q = A[X-1]
    if P==Q:
        B[X-1] = 0
    else:
        XDL = make_divisors(X)
        for XD in XDL:
            B[XD-1] = 1 - B[XD-1]
out = []
cnt = 0
for i in range(N):
    if B[i]==1:
        out.append(i+1)
        cnt+=1
print(cnt)
if len(out)>0:
    print(*out)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
aaa = list(map(int, input().split()))
M = 0
bbb = []
for i in range(2, N + 1):
    if sum(aaa[i - 1::i]) % 2 == 1:
        M += 1
        bbb.append(i)
if (M + aaa[0]) % 2 == 1:
    M += 1
    bbb.append(1)
print(M)
if M > 0:
    print(*bbb)

Submission status: Wrong Answer

Solution code:
N = int(input())
aaa = list(map(int, input().split()))
M = 0
for i in range(1, N + 1):
    if sum(aaa[i - 1::i]) % 2 == 1:
        M += 1
print(M)
if M > 0:
    bbb = [1] * M
    print(*bbb)

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):
    count = 0
    for j in range(i, n, i+1):
        count += ans[j]
    if count % 2 != a[i]:
        ans[i] = 1

if sum(ans) == 0:
    print(0)
    exit()

print(sum(ans))
for i in range(n):
    if ans[i] != 0:
        print(ans[i], 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):
    count = 0
    for j in range(i, n, i+1):
        count += ans[j]
    if count % 2 != a[i]:
        ans[i] = 1

if sum(ans) == 0:
    print(0)
    exit()

print(sum(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
index = []
M = 0
for i in range(N-1,-1,-1):
    if sum(A[i:N:i+1]) % 2 == 0:
        ans[i] = 0
    else:
        ans[i] = 1
        index.append(i+1)
        M += 1
print(M)
print(*index[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
index = []
M = 0
for i in range(N-1,-1,-1):
    if sum(A[i:N:i+1]) % 2 == 0:
        ans[i] = 0
    else:
        ans[i] = 1
        index.append(i+1)
        M += 1
print(M,*index,sep='\n')

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans = [-1 for i in range(n)]
    for i in range(n):
        c = n//(n-i)
        if c<2:
            if a[n-1-i] == 1:
                ans[n-1-i] = 1
            else:
                ans[n-1-i] = 0
        else:
            s = 0
            for j in range(2,c):
                s += ans[j*(n-i)]
            ans[n-i-1] = (s+a[n-1-i])%2 
    a = []
    for i in range(n):
        if ans[i] == 1:
            a.append(i+1)
    if len(a)==0:
        print(0)
    else:
        print(len(a))
        print(' '.join(list(map(str,a))))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
bits = list(map(int,input().split()))
ans = set()
for i in reversed(range(n)):
  for j in range(i+(i+1),n,i+1):
    bits[i] ^= bits[j]
  if bits[i] == 1:
    ans.add(i+1)
print(len(ans))
print(*ans)
n= 3
for i in reversed(range(n)):
  for j in range(i+(i+1),n,i+1):
    print(i,j)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    a = list(map(int, input().split()))
    A = [0] + a
    B = [0] * (N + 1)

    for i in range(N, 0, -1):
        j = 2
        count = 0
        while i * j <= N:
            count += B[i * j]
            j += 1
        if (count + A[i]) % 2 == 0:
            pass
        else:
            B[i] = 1
    print(sum(B))

    for i in range(len(B)):
        if B[i]==1:
            print(i,end="")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    a = list(map(int, input().split()))
    A = [0] + a
    B = [0] * (N + 1)

    for i in range(N, 0, -1):
        j = 2
        count = 0
        while i * j <= N:
            count += B[i * j]
            j += 1
        if (count + A[i]) % 2 == 0:
            pass
        else:
            B[i] = 1
    B.pop(0)
    print(*B)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n):
    num1=n-i
    num2=0
    for j in range((n//num1)-1):
        num2+=ans[num1*(j+2)-1]
    num2%=2
    ans[-1-i]=(num2+a[-1-i])%2
print(ans.count(1))
print(*ans)

Submission status: Wrong Answer

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

def main(n,a):
    a.insert(0,0)
    b=[0]*(n+1)
    for i in range(n,0,-1):
        sum=0
        j=i*2
        while(j<=n):
            sum+=b[j]
            j+=i
        b[i]=(a[i]-(sum%2)+2)%2
    ans=[]
    for i in range(1,n+1):
        if b[i]!=0:
            ans.append(b[i])
    return ans

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(len(ans))
    if len(ans)>0:
        print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
aas = list(map(int, input().split()))

res = [0]*n
cnts = [0]*n
for i in reversed(range(n)):
    if aas[i] == 0:
        if cnts[i]%2 != 0:
            res[i] = 1
    else:
        if cnts[i]%2 == 0:
            res[i] = 1
            for j in make_divisors(i+1):
                cnts[j-1] += 1

res_tmp = sum(res)
print(res_tmp)
if res_tmp:
    res_tmp = ""
    for i in range(n):
        if res[i] == 1:
            res_tmp += str(i+1) + " "
    print(res_tmp[:-1])

Submission status: Wrong Answer

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

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

print(sum(b))
if sum(b) > 0:
    print(*[i + 1 for i in range(n) if b[i] == 1])

Submission status: Wrong Answer

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

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

print(sum(b))
if sum(b) > 0:
    print(*[i+1 for i in range(n) if b[i] == 1])

Submission status: Wrong Answer

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

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

print(sum(b))
if sum(b) > 0:
    print(*[i for i in b if i == 1])

Submission status: Wrong Answer

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

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

print(sum(b))
if sum(b) > 0:
    print(*[i for i in b if i == 1])

Submission status: Wrong Answer

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

def cnt_rem(ans, x):
    i = 2
    ret = 0
    while (x + 1) * i <= n:
        ret += ans[(x + 1) * i - 1]
        i += 1
    
    return ret

for i in range(n - 1, -1, -1):
    cnt = cnt_rem(ans, i)
    if cnt != a[i]:
        ans[i] += 1

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

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = [0] + LIST()
b = [0]*(n+1)

for i in range(n, 0, -1):
    j = i + i
    tmp = 0
    while j <= n:
        tmp += b[j]
        j += i
    if tmp != a[i]:
        b[i] = 1

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0]*n
for i in range(n,0,-1):
  s=0
  t=i
  while t<=n:
    s+=a[t]
    t+=i
  if s%2==a[i]%2:
    b[i-1]=a[i]%2
  else:
    b[i-1]=(a[i]+1)%2
ans=0
c=[]
for i,bb in enumerate(b):
  if bb>0:
    ans+=bb
    c.append(i+1)
print(ans)
print(*c)

Submission status: Wrong Answer

Solution code:
def divs(num):
    ans = []
    for i in range(1,int(num**(1/2)+1)):
        if num%i == 0:
            ans += [i,num//i]
    return set(ans)
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n+1)
for i in range(n,0,-1):
    # print(i,a[i-1],ans[i])
    if a[i-1]^ans[i]:
        div = divs(i)
        # print(div)
        for j in div:
            ans[j] ^= 1
cnt = 0
fin = []
for i in range(1,n+1):
    if ans[i] == 1:
        cnt += 1
        fin += [i]
print(cnt)
print(*fin)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from functools import reduce, lru_cache
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N = I()
    A = LI()

    ans = []

    for i in range(1, N+1):
        j = 1
        tmp = 0
        while i * j <= N:
            tmp ^= A[i * j - 1]
            j += 1
        if tmp:
            ans.append(i)
    print(len(ans))
    print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
data = list(map(int, input().split()))
balls = []

for idx in range(n):
    score = 0
    for idx2 in range(2*idx+1, n, idx+1):
        score += data[idx2]
    if score%2 != data[idx]:
        balls.append(idx+1)

print(len(balls))
if len(balls) > 0:
    print(' '.join(map(str, balls)))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))[::-1]
ans = []
for i in range(n-1,-1,-1):
    t = A[i]
    for j in range(2*i+1,n+1,i+1):
        if i<j<n:
            t += A[j]
    if t%2!=A[i]:
        ans.append(i+1)
print(len(ans))
if len(ans)>0:
    print(*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = rl()

B = [0] * N

R = [0] * N
for i in range(N-1, -1, -1):
	if R[i] % 2 == A[i]:
		B[i] = 0
	else:
		B[i] = 1
		n = i+1
		j = 1
		while j*j <= n:
			if n % j == 0:
				R[j-1] += 1
			j += 1

ans = [i+1 for i, b in enumerate(B) if b == 1]
print(len(ans))
print(*ans)