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 resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j]

        if As[num-1] == 1:
            if sum_num % 2 == 0:
                res[num-1] += 1
        else:
            if sum_num % 2 == 1:
                res[num-1] += 1
    
    print(sum(res))
    for item in res:
        if item != 0:
            print(item)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    if As[0] % 2 == 0:
        print(0)
    else:
        print(1)
        print(1)    


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

ans=[0 for _ in range(n+1)]
t=''
S=0

for i in range(n):
  b=n-i
  c=(n-i)*2
  ch=0
  while c<=n:
    ch+=ans[c]
    c+=b
    
  if ch%2==0:
    if a[b-1]==1:
      ans[b]+=1
      S+=1
      t=str(b)+' '
  else:
    if a[b-1]!=1:
      ans[b]+=1
      S+=1
      t=str(b)+' '
      

print(S)
if S>0:
  
  print(t)

Submission status: Wrong Answer

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

ans=[0 for _ in range(n+1)]

for i in range(1,n):
  b=n-i
  c=(n-i)*2
  ch=0
  x=a[b]
  while c<=n:
    ch+=ans[c]
    c+=b
    
  if ch%2==0:
    if a[b-1]==1:
      ans[b]+=1
  else:
    if a[b-1]!=1:
      ans[b]+=1
      
ans.remove(ans[0])
S=sum(ans)
print(S)
t=''
if S>0:
  for r in range(n):
    if ans[r]==1:
      t+=str(r+1)+' '
      
  print(t)

Submission status: Wrong Answer

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

ans=[0 for _ in range(n+1)]

yaku=[0 for _ in range(n+1)]

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]
  

ans1=0
for i in range(n):
  b=n-i
  ch=0
  if yaku[b]%2==1:
    if a[b-1]==0:
      ans[b]=1
      ch+=1
      ans1+=1
  else:
    if a[b-1]==1:
      ans[b]=1
      ch+=1
      ans1+=1
  if ch==1:
    
    for A in make_divisors(b):
      yaku[A]+=1
      
print(ans1)
t=''

if ans1>0:
  for h in range(n):
    if ans[h]==1:
      t+=str(h)+' '
  print(t)

Submission status: Wrong Answer

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

ans=[0 for _ in range(n+1)]

for i in range(1,n):
  b=n-i
  c=(n-i)*2
  ch=0
  x=a[b]
  while c<=n:
    ch+=ans[c]
    c+=b
    
  if ch%2==0:
    if a[b-1]==1:
      ans[b]+=1
  else:
    if a[b-1]!=1:
      ans[b]+=1
      
ans.remove(ans[0])
S=sum(ans)
print(S)
t=''
if S>0:
  for r in range(n):
    if ans[r]==1:
      t+=str(r+1)+' '
      
print(t)

Submission status: Wrong Answer

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

for j in range(N,0,-1):
  cnt = 0
  for k in res:
    if k%j == 0:
      cnt += 1
  if A[j] == 1 and cnt%2 == 0:
    res.append(j)
  elif A[j] == 0 and cnt%2 == 1:
    res.append(j)
  
res.sort()
M = len(res)
if M == 0:
  print(-1)
else:
  print(M)
  print(*res)

Submission status: Wrong Answer

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

for j in range(N-1,0,-1):
  cnt = 0
  for k in res:
    if k%j == 0:
      cnt += 1
  if A[j] == 1 and cnt%2 == 0:
    res.append(j)
  elif A[j] == 0 and cnt%2 == 1:
    res.append(j)
  
res.sort()
M = len(res)
if M == 0:
  print(-1)
else:
  print(M)
  print(*res)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if i > 0 - -n//2:
        l[i] = a[i]
    else:
        l[i] = sum(a[i::i])%2

print(l.count(1))

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

Submission status: Wrong Answer

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=[0]+LI()
    b=[0]*(N+1)
    
    
    for i in range(N-1,0,-1):
        temp=0
        for j in range(2*i,N+1,i):
            if b[j]:
                temp+=1
        temp=temp%2
        if temp!=a[i]:
            b[i]=1
            
    M=sum(b)
    ans=[]
    for i in range(N):
        if b[i]:
            ans.append(i)
            
    print(M)
    print(' '.join(map(str, ans)))
        

main()

Submission status: Wrong Answer

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=[0]+LI()
    b=[0]*(N+1)
    
    
    for i in range(N-1,0,-1):
        temp=0
        for j in range(2*i,N,i):
            if b[j]:
                temp+=1
        temp=temp%2
        if temp!=a[i]:
            b[i]=1
            
    M=sum(b)
    ans=[]
    for i in range(N):
        if b[i]:
            ans.append(i)
            
    print(M)
    print(' '.join(map(str, ans)))
        

main()

Submission status: Wrong Answer

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    b=[0]*N
    
    
    for i in range(N-1,-1,-1):
        temp=0
        for j in range(2*i+2,N,i+1):
            jj=j-1
            if b[jj]:
                temp+=1
        temp=temp%2
        if temp!=a[i]:
            b[i]=1
            
    M=sum(b)
    ans=[]
    for i in range(N):
        if b[i]:
            ans.append(i+1)
            
    print(M)
    print(' '.join(map(str, ans)))
        

main()

Submission status: Wrong Answer

Solution code:
n=int(input())

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

l=[-1 for _ in range(n)]
for i in reversed(range(1,n+1)):
    si=0
    j=2*i-1
    while j<=n-1:
        si+=l[j]
        j+=i
    si=si%2
    if si==0:
        l[i-1]=a[i-1]

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

print(len(b))
if len(b)!=0:
    print(*b)

Submission status: Wrong Answer

Solution code:
print(-1)

Submission status: Wrong Answer

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

ball = [0 for i in range(n)]

for i in reversed(range(n)):
  if n//2 < i:
    ball[i] = a[i]
  else:
    if (sum(ball[i::(i+1)]) - a[i]) % 2 == 0:
      ball[i] = 0
    else:
      ball[i] = 1

print(ball)

num = [str(i+1) for i, x in enumerate(ball) if x == 1]
print(num)

if len(num) == 0:
  print('0')
else:
  print(len(num))
  num = ' '.join(num)
  print(num)

Submission status: Wrong Answer

Solution code:

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

ball = [0 for i in range(n)]

for i in reversed(range(n)):
  if n//2 < i:
    ball[i] = a[i]
  else:
    if (sum(ball[i::(i+1)]) - a[i]) % 2 == 0:
      ball[i] = 0
    else:
      ball[i] = 1

num = [str(i+1) for i, x in enumerate(a) if x == 1]
if len(num) == 0:
  print('0')
else:
  print(len(num))
  num = ' '.join(num)
  print(num)

Submission status: Wrong Answer

Solution code:
import sys

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

if a[0] != sum(a) % 2:
  print('-1')
  sys.exit()

for i in range(1, n):
  new_a = a[i:n:(i+1)]
  if a[i] != sum(new_a) % 2:
    print('-1')
    sys.exit()
  
num = [str(i+1) for i, x in enumerate(a) if x == 1]

if len(num) == 0:
  print('0')
else:
  print(len(num))
  num = ' '.join(num)
  print(num)

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())
D=[[1]for _ in range(N+1)]
for i in range(2,N+1):
    j=1
    while i*j<=N:
        D[i*j].append(i)
        j+=1

D=D[:-1]
B=[0]*N
ans=[]
i=1
while i<=N:
    B[-i]%=2
    if B[-i]==A[-i]:
        i+=1
        continue
    else:
        ans.append(N-i+1)
        for d in D[-i]:
            B[d-1]+=1
        B[-i]%=2
    i+=1
        
M=len(ans)
ans.sort()
print(M)
print(*ans)

Submission status: Wrong Answer

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

N = cin()[0]
a = cin()

ans = [0 for _ in range(N + 1)]
rec = [0 for _ in range(N + 10)]

for i in range(1, N + 1):
    if rec[i] == a[i - 1]:  continue
    else:
        ans[i] = 1
        tmp = i
        while(tmp <= N):
            rec[tmp] = (1 + rec[tmp]) % 2
            tmp += i

l = []
for i in range(1, N + 1):
    if ans[i]:  l.append(i)
if len(l):
    print(len(l))
    print(*l)
else:  print(-1)

Submission status: Wrong Answer

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

N = cin()[0]
a = cin()

ans = [0 for _ in range(N + 1)]
rec = [0 for _ in range(N + 10)]

for i in range(1, N + 1):
    if rec[i] == a[i - 1]:  continue
    else:
        ans[i] = 1
        tmp = i
        while(tmp <= N):
            rec[tmp] = (1 + rec[tmp]) % 2
            tmp += i

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + list(map(int, input().split()))
Ans = [0] * (N+1)
for i, a in zip(range(N, 0, -1), A[:0:-1]):
    n = 0
    for aj in Ans[i*2::i]:#range(i, N+1, i):
        n ^= aj
    Ans[i] = n ^ a
Ans = [i for i, a in enumerate(A[1:], 1) if a]
print(len(Ans))
print(" ".join(map(str, Ans)))

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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())
a=[0]
a.extend(lmp())
l=[0]*(n+1)#iの倍数の箱にいくつ玉が入っているか
ans=[]

for i in range(n,0,-1):
    if (l[i]-a[i])%2==1:
        ans.append(i)
        for k in make_divisors(n):
            l[k]+=1
print(len(ans))
print(*ans[::-1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def count(k, bins, N):
    current = 0
    for i in range(2, N):
        if k * i <=N:
            if bins[k*i] == -1:raise ValueError(f'bins{i} is not filled yet')
            current += bins[k*i]
        else:
            break
    return current % 2

def check(bins):
    for b in bins[1:]:
        if b == -1:
            return False
    return True

def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    A = [-1] + A
    bins = [-1] * (N+1)

    for i in range(N, 0, -1):
        tmp =(A[i] - count(i, bins, N)) % 2
        if bins[i] == -1 or bins[i] == tmp:
            bins[i] = tmp
        else:
            print(-1)
            return

    if check(bins):
        print(sum(bins) + 1)
        ans = []
        for i, b in enumerate(bins):
            if b == 1:
                ans.append(str(i))
        print(' '.join(ans))

    else:
        print(-1)

if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def count(k, bins, N):
    current = 0
    for i in range(2, N):
        if k * i <=N:
            if bins[k*i] == -1:raise ValueError(f'bins{i} is not filled yet')
            current += bins[k*i]
        else:
            break
    return current % 2

def check(bins):
    for b in bins[1:]:
        if b == -1:
            return False
    return True

def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    A = [-1] + A
    bins = [-1] * (N+1)

    for i in range(N, 0, -1):
        tmp =(A[i] - count(i, bins, N)) % 2
        if bins[i] == -1 or bins[i] != tmp:
            bins[i] = tmp
        else:
            print(-1)
            return

    if check(bins):
        print(sum(bins) + 1)
        ans = []
        for i, b in enumerate(bins):
            if b == 1:
                ans.append(str(i))
        print(' '.join(ans))

    else:
        print(-1)

if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def count(k, bins, N):
    current = 0
    for i in range(2, N):
        if k * i <=N:
            if bins[k*i] == -1:raise ValueError(f'bins{i} is not filled yet')
            current += bins[k*i]
        else:
            break
    return current % 2

def check(bins):
    for b in bins[1:]:
        if b == -1:
            return False
    return True

def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    A = [-1] + A
    bins = [-1] * (N+1)

    for i in range(N, 0, -1):
        tmp =(A[i] - count(i, bins, N)) % 2
        if bins[i] == -1 or tmp:
            bins[i] = tmp
        else:
            print(-1)
            return

    if check(bins):
        print(sum(bins) + 1)
        ans = []
        for i, b in enumerate(bins):
            if b == 1:
                ans.append(str(i))
        print(' '.join(ans))

    else:
        print(-1)

if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def count(k, bins, N):
    current = 0
    for i in range(2, N):
        if k * i <=N:
            if bins[k*i] == -1:raise ValueError(f'bins{i} is not filled yet')
            current += bins[k*i]
        else:
            break
    return current % 2

def check(bins):
    for b in bins[1:]:
        if b == -1:
            return False
    return True

def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    A = [-1] + A
    bins = [-1] * (N+1)

    for i in range(N, 0, -1):
        bins[i] = (A[i] - count(i, bins, N)) % 2

    if check(bins):
        print(sum(bins) + 1)
        ans = []
        for i, b in enumerate(bins):
            if b == 1:
                ans.append(str(i))
        print(' '.join(ans))

    else:
        print(-1)

if __name__ == "__main__":
    run()

Submission status: Wrong Answer

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

b=[0]*n
for i in range(n//2,n):
    b[i]=a[i]
#    print(i,a[i])
    
for i in range(n//2-1,-1,-1):
    i2=(i+1)*2
    asum=0
    while i2<n:
        asum+=b[i2-1]
        i2+=i+1
    b[i]=(asum+a[i])%2
#    print(i,b[i],a[i],asum)
    
print(sum(b))
for i in range(len(b)):
    if b[i]==1:
        print(i+1,end=" ")
print(" ")

Submission status: Wrong Answer

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

b=[0]*n
for i in range(n//2,n):
    b[i]=a[i]
#    print(i,a[i])
    
for i in range(n//2-1,-1,-1):
    i2=(i+1)*2
    asum=0
    while i2<n:
        asum+=b[i2]
        i2+=i+1
    b[i]=(asum+a[i])%2
#    print(i,b[i],a[i],asum)
    
#print(sum(b))
for i in range(len(b)):
    if b[i]==1:
        print(i+1,end=" ")
print(" ")

Submission status: Wrong Answer

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

b=[0]*n
for i in range(n//2,n):
    b[i]=a[i]
#    print(i,a[i])
    
for i in range(n//2-1,-1,-1):
    i2=(i+1)*2
    asum=0
    while i2<n:
        asum+=b[i2]
        i2+=i+1
    b[i]=(asum+a[i])%2
#    print(i,b[i],a[i],asum)
    
print(sum(b))
for i in range(len(b)):
    if b[i]==1:
        print(i+1,end=" ")
print(" ")

Submission status: Wrong Answer

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

# 箱に書かれた数字が大きい順にボールを入れるか決定していくとi以上のiの倍数
# についてはすでにボールを入れるか入れないかを決定している

ans = [0] * N
for i in range(N - 1, -1, -1):
    if (i == N - 1):
        sum_a = a[i]
    elif (i == 0):
        sum_a = sum(a)
    else:
        sum_a = sum(a[i:-1:(i + 1)])
    sum_a -= a[i]
    if (a[i] == 0 and sum_a % 2 == 0):
        continue
    elif(a[i] == 0 and sum_a % 2 == 1):
        ans[i] = 1
    elif (a[i] == 1 and sum_a % 2 == 0):
        ans[i] = 1
    elif (a[i] == 1 and sum_a % 2 == 1):
        continue
    else:
        print(-1)
        exit()

M = 0
new_ans = []
for i in range(N):
    if (ans[i] == 1):
        M += 1
        new_ans.append(i + 1)

if (M == 0):
    print(M)
    exit()
print(M)
print(*new_ans)

Submission status: Wrong Answer

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

# 箱に書かれた数字が大きい順にボールを入れるか決定していくとi以上のiの倍数
# についてはすでにボールを入れるか入れないかを決定している

ans = [0] * N
for i in range(N - 1, -1, -1):
    if (i == N - 1):
        sum_a = a[i]
    elif (i == 0):
        sum_a = sum(a)
    else:
        sum_a = sum(a[i:-1:(i + 1)])
    sum_a -= a[i]
    if (a[i] == 0 and sum_a % 2 == 0):
        continue
    elif(a[i] == 0 and sum_a % 2 == 1):
        ans[i] = 1
    elif (a[i] == 1 and sum_a % 2 == 0):
        ans[i] = 1
    elif (a[i] == 1 and sum_a % 2 == 1):
        continue
    else:
        print(-1)
        exit()

M = 0
new_ans = []
for i in range(N):
    if (ans[i] == 1):
        M += 1
        new_ans.append(i + 1)

print(M)
print(*new_ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
l = [-1] + list(map(int,input().split()))

dp = [-1]+[0]*n

for i in range(n,0,-1):
    j = 1
    isum = 0
    while j*i <= n:
        isum += dp[j*i]
        j += 1
    if isum%2 != l[i]%2:
        dp[i] =  1

ans = [i for i in range(1,n) if dp[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()))
b = []
c = []
for i in range(N):
    if i<N//2:
        b.append(-1)
    else:
        b.append(a[i])

for i in reversed(range(N//2)):
    t = 1
    s = 0
    while (i+1)*(t+1)<=N:
        s+=b[(i+1)*(t+1)-1]
        t+=1
    if s%2 != a[i]:
        b[i]=1
    else:
        b[i]= 0
#print(b)

bo = False
for j in range(N):
    if b[j]==1:
        bo = True
        c.append(str(j+1))
if bo:
    print(" ".join(c))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = []
c = []
for i in range(N):
    if i<N//2:
        b.append(-1)
    else:
        b.append(a[i])

for i in reversed(range(N//2)):
    t = 1
    s = 0
    while (i+1)*(t+1)<=N:
        s+=b[(i+1)*(t+1)-1]
        t+=1
    if s%2 != a[i]:
        b[i]=1
    else:
        b[i]= 0
#print(b)

bo = False
for j in range(N):
    if b[j]==1:
        bo = True
        c.append(str(j+1))
if bo:
    print("".join(c))
else:
    print(0)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
m = 0
b = []
cnt = [defaultdict(int) for _ in range(n+1)]
for i in range(1, n+1):
    j = i
    c = 2
    while j <= n:
        cnt[j][i] = 1
        j *= c
        c += 1

tmp = [0]*(n+1)
for i in range(n)[::-1]:
    if tmp[i+1] % 2 != a[i]:
        b.append(i+1)
        m += 1
        for j, k in cnt[i+1].items():
            if k == 1:
                tmp[j] += 1
print(m)
print(*b[::-1])

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
m = 0
b = []
cnt = [defaultdict(int) for _ in range(n+1)]
for i in range(1, n):
    j = i
    c = 2
    while j < n:
        cnt[j][i] = 1
        j *= c
        c += 1

tmp = [0]*(n+1)
for i in range(n)[::-1]:
    if tmp[i+1] % 2 != a[i]:
        b.append(i+1)
        m += 1
        for j in cnt[i+1].keys():
            tmp[j] += 1
print(m)
print(*b[::-1])

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
m = 0
b = []
cnt = [defaultdict(int) for _ in range(n+1)]
for i in range(1, n):
    j = i
    c = 2
    while j < n:
        cnt[j][i] = 1
        j *= c
        c += 1

tmp = [0]*(n+1)
for i in range(n)[::-1]:
    if tmp[i+1] % 2 != a[i]:
        b.append(i+1)
        m += 1
        for j in cnt[i].keys():
            tmp[j] += 1
print(m)
print(*b[::-1])

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())

A = [0] + A
B = [0] * (N + 1)
sum_B = 0
for i in range(N, 0, -1):
    if sum(B[j] for j in range(i, N + 1, i)) != A[i]:
        B[i] = 1
        sum_B += 1
print(sum_B)
print(*[i for i, b in enumerate(B) if b])

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())

A = [0] + A
B = [0] * (N + 1)
sum_B = 0
for i in range(N, 0, -1):
    if sum(B[j] for j in range(i, N, i)) != A[i]:
        B[i] = 1
        sum_B += 1
print(sum_B)
print(*[i for i, b in enumerate(B) if b])

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())

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

Submission status: Wrong Answer

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


ball = [0] * (n + 1)
ans = []

for i in range(n, 0, -1):
    s = 0
    j = i * 2
    while j < n:
        s += ball[j]
        j += i

    if s % 2 != a[i]:
        ball[i] += 1
        ans.append(i)

print(len(ans))
for e in ans:
    print(e)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
B = [0 for _ in range(N+1)]
for i in range((N+1)//2,N+1):
    B[i] = A[i]
for i in range((N+1)//2-1,0,-1):
    cnt = A[i]
    for j in range(2,N//i+1):
        cnt = (cnt+B[j])%2
    B[i] = cnt
C = []
for i in range(1,N+1):
    if B[i]==1:
        C.append(i)
print(len(C))
print(*C)

Submission status: Wrong Answer

Solution code:
n = int(input())
al = list(map(int, input().split()))
boxs = []
cnts = [0]*(n+1)
for i in range(n,0,-1):
    # print(i, boxs, cnts)
    if cnts[i]%2 != al[i-1]:
        boxs.append(i)
        for j in range(1, int(i**0.5)+1):
            if n%j == 0:
                cnts[j] += 1
                if j*j != i: cnts[n//j] += 1

print(len(boxs))
for b in boxs: print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
al = list(map(int, input().split()))
boxs = [0]*(n+1)
cnts = [0]*(n+1)
for i in range(n,0,-1):
    # print(i, boxs, cnts)
    if cnts[i]%2 != al[i-1]:
        boxs[i] += 1
        for j in range(1, int(i**0.5)+1):
            if n%j == 0:
                cnts[j] += 1
                if j*j != i: cnts[n//j] += 1

print(*cnts[1:])

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans = [0]*N
for i in range(N):
    target = N-1-i
    tmp = 0
    for k in range(target,N):
        tmp += ans[k]
    if tmp % 2 == arr[target]:
        ans[target] = 0
    else:
        ans[target] = 1
ans2 = []
for i in range(N):
    if ans[i] == 1:
        ans2.append(i+1)
print(len(ans2))
print(*ans2)

Submission status: Wrong Answer

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

B=[0 for i in range(n)]
B[n//2:]=A[n//2:]

for i in range(n//2,1,-1):
    B[i-1]= A[2*i-1] ^ A[i-1]

B[0]= (sum(B)^A[0])%2
print(sum(B))
for i,j in enumerate(B):
    if j==1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
*a, = map(int, input().split())
b = [0]*(n//2) + a[n//2:]
for i in reversed(range(n//2)):
    b[i] = sum(b[(i+1)*(j+1)-1] for j in range(n//(i+1)))>>0 ^ a[i]
print(sum(b))
print(*[i+1 for i in range(n) if b[i]==1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n,*a=map(int, open(0).read().split())
b = [0]*(n//2) + a[n//2:]
for i in reversed(range(n//2)):
    b[i] = sum(b[(i+1)*(j+1)-1] for j in range(n//(i+1)))%2 ^ a[i]
print(sum(b))
print(*[i for i in b if i==1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n,*a=map(int, open(0).read().split())
b = [0]*(n//2) + a[n//2:]
for i in reversed(range(n//2)):
    b[i] = sum(b[(i+1)*(j+1)-1] for j in range(n//(i+1))) ^ a[i]
print(sum(b))
print(*[i for i in b if i==1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n,*a=map(int, open(0).read().split())
b = [0]*(n//2) + a[-(-n//2):]
for i in reversed(range(n//2)):
    b[i] = sum(b[(i+1)*~-j-1] for j in range(n//(i+1))) ^ a[i]
print(sum(b))
print(*[i for i in b if i==1])

Submission status: Wrong Answer

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

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

num = sum(a)
if num == 0:
    print(0)
else:
    print(num)
    for i in range(n):
        if a[i] != 0:
            print(i+1, end=' ')
    print('')

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    val = 0
    for j in range(i, n+1, i):
        val += a[j-1]
    if val%2 != a[i-1]:
        a[i-1] += 1
        if a[i-1] > 1:
            print(-1)
            sys.exit()

num = sum(a)
if num == 0:
    print(0)
else:
    print(num)
    for i in range(n):
        if a[i] != 0:
            print(i+1, end=' ')
    print('')

Submission status: Wrong Answer

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

sum_a = [0]*(2*N+10)

for n in range(N-1,-1,-1):
    a = A[n]
    sum_a_temp = sum_a[2*a]
    if sum_a_temp% 2 == a:
        sum_a[n] = sum_a_temp
    else:
        sum_a[n] = sum_a_temp + 1
        
ans_list = []  
for s_ in range(len(sum_a[:N])):
    s=sum_a[s_]
    if s == 1:
        ans_list.append(s_+1)
        
print(len(ans_list))
if len(ans_list)>0:
    print(' '.join(map(str,ans_list)))

Submission status: Wrong Answer

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

for i in reversed(range(N)):
  i_original = i+1
  i_multiple = i+1
  tmp = 0
  while i_multiple <= N:
    tmp += a[i-1]
    i_multiple += i_original
  if tmp % 2 == 0:
    a[i] += 1
    ans.append(i+1)

ans.sort()
if len(ans) == 0:
  print(-1)
else:
  print(len(ans))
  print(' '.join(map(str,ans)))

Submission status: Wrong Answer

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

for i in reversed(range(N)):
  i_original = i+1
  i_multiple = i+1
  tmp = 0
  while i_multiple <= N:
    tmp += a[i-1]
    i_multiple += i_original
  if tmp % 2 == 0:
    a[i] += 1
    ans.append(i+1)

ans.sort()
print(' '.join(map(str,ans)))