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=[0]*n
c=0
for i in range(n):
    c+=a[i]%2
    if a[i]%2==1:
        b[i]+=i+1
print(sum(b))
print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = [0] + [int(x) for x in input().split()]

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
p_list = primes(n)

count_list = [0] * (n + 1)

ans_list = []
for i in range(n, 0, -1):
    if count_list[i] % 2 != a_list[i]:
        ans_list.append(i)
        
        count_list[1] += 1
        count_list[i] += 1
        
        if i in p_list:
            continue

        for j in range(2, int(i ** 0.5) + 1):
            if i % j == 0:
                count_list[j] += 1

print(len(ans_list))
for ans in ans_list:
    print(ans, end=" ")

Submission status: Wrong Answer

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

prime = [2]
for L in range(3, n, 2):
    if all(L % L2 != 0 for L2 in prime):
        prime.append(L)
prime.sort()

l = []
for i in range(n, 0, -1):
    if i > n//2 and a[i-1] == 1:
        l.append(i)
    elif i <= n//2:
        tmp = 0
        cnt = 0
        while tmp < len(prime) and i*prime[tmp] <= n:
            cnt += a[prime[tmp]-1]
            tmp += 1
        if cnt%2 != a[i-1]:
            l.append(i)
print(len(l))
print(" ".join(map(str, l)))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
e=0
for i in range(n):
    c=n-i
    d=0
    while c<=n:
        b[c-1]+=d
        c+=(n-i)
    if d%2!=a[n-i-1]:
        b[-i-1]+=1
        e+=1
print(e)
for i in range(n):
    if b[i]!=0:
        print(i+1,end=' ')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
ans = [a[n-1]]
if n == 1:
  print(a)
  exit()
  
for i in range(n-2,-1,-1):
  if i+1 > n//2:
    ans.append(a[i])
  else:
    ans.append((sum(ans[n%(i+1)::(i+1)])-a[i])%2)
    
print(sum(ans))
chk = []
for i,ai in enumerate(ans):
  if ai == 1:
    chk.append(n-i)
print(*chk)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
ans = [a[n-1]]
if n == 1:
  print(a)
  exit()
  
for i in range(n-2,-1,-1):
  if n%(i+1) != 0:
    ans.append(a[i])
  else:
    ans.append((sum(ans[::(i+1)])-a[i])%2)
    
print(sum(ans))
chk = []
for i,ai in enumerate(ans):
  if ai == 1:
    chk.append(n-i)
print(*chk,sep='\n')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
b = [-1] * n
m = 0
ans = set()
for i in range(n, 0, -1):
    if b[i - 1] >= 0:
        continue
    
    b[i - 1] = A[i - 1]
    is_odd = b[i - 1] % 2 == 1
    if is_odd:
        ans.add(i)

    num = i
    while num % 2 == 0:
        num //= 2
        if A[num - 1] % 2 == 0:
            is_put = 1 if is_odd else 0
            is_odd = False
        else:
            is_put = 0 if is_odd else 1
            is_odd = True
        
        if b[num - 1] >= 0 and b[num - 1] != is_put:
            m = -1
            break
        
        b[num - 1] = is_put
        if is_put:
            ans.add(num)

if m < 0:
    print(m)
else:
    m = len(ans)
    print(m)
    if m > 0:
        print(*ans)

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    items = [0]*N
    count = 0
    #greedy
    for i in range(N):
        if i == (N+1) // 2:
            count = N-i
            break
        items[-1-i] = a[-1-i]
    for j in range(count,0,-1):
        balls = 0
        for k in range(2, (N+j-1)//j):
            balls +=items[k*j]
            if balls > a[j-1]:
                print(-1)
                exit()
        if a[j-1] == balls%2:
            items[j-1] = 0
        else:
            items[j-1] = 1
    print(sum(items))
    if sum(items) == 0:
        exit()
    print(*items)



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
ans = [a[n-1]]
if n == 1:
  print(a)
  exit()
  
for i in range(n-2,-1,-1):
  if n%(i+1) != 0:
    ans.append(a[i])
  else:
    ans.append((sum(ans[::(i+1)])-a[i])%2)
    
print(sum(ans))
chk = []
for i,ai in enumerate(ans):
  if ai == 1:
    chk.append(n-i)
print(*chk[::-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
b = [-1] * n
m = 0
ans = set()
for i in range(n, 0, -1):
    if b[i - 1] >= 0:
        continue
    stat = 0 if A[i - 1] % 2 == 0 else 1
    b[i - 1] = stat
    if b[i - 1] == 1:
        ans.add(i)
    num = i
    while num % 2 == 0:
        num //= 2
        if A[num - 1] % 2 == 0:
            b[num - 1] = 0 if stat == 0 else 1
            stat = 0
        else:
            b[num - 1] = 1 if stat == 0 else 0
            stat = 1
        if b[num - 1] == 1:
            ans.add(num)

m = sum(b)
print(m)
if m > 0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
b = [-1] * n
m = 0
ans = set()
for i in range(n, 0, -1):
    if b[i - 1] >= 0:
        if b[i - 1] != A[i - 1]:
            m = -1
            break
        else:
            continue
    stat = 0 if A[i - 1] % 2 == 0 else 1
    b[i - 1] = stat
    if b[i - 1] == 1:
        ans.add(i)
    num = i
    while num % 2 == 0:
        num //= 2
        if A[num - 1] % 2 == 0:
            b[num - 1] = 0 if stat == 0 else 1
            stat = 0
        else:
            b[num - 1] = 1 if stat == 0 else 0
            stat = 1
        if b[num - 1] == 1:
            ans.add(num)

if m < 0:
    print(m)
else:
    m = sum(b)
    print(m)
    if m > 0:
        print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
b = [-1] * n
m = 0
ans = set()
for i in range(n, 0, -1):
    if b[i - 1] >= 0 and b[i - 1] != A[i - 1]:
        m = -1
        break
    stat = 0 if A[i - 1] % 2 == 0 else 1
    b[i - 1] = stat
    if b[i - 1] == 1:
        ans.add(i)
    num = i
    while num % 2 == 0:
        num //= 2
        if A[num - 1] % 2 == 0:
            b[num - 1] = 0 if stat == 0 else 1
            stat = 0
        else:
            b[num - 1] = 1 if stat == 0 else 0
            stat = 1
        if b[num - 1] == 1:
            ans.add(num)

if sum(b) > 0:
    print(sum(b))
    print(*ans)
else:
    print(m)

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    items = [0]*N
    count = 0
    #greedy
    for i in range(N):
        if i == (N+1) // 2:
            count = N-i
            break
        items[-1-i] = a[-1-i]
    for j in range(count,0,-1):
        balls = 0
        for k in range(2, (N+j-1)//j):
            balls +=items[k*j]
            if balls > a[j-1]:
                print(-1)
                exit()
        items[j-1] = a[j-1] - balls

        
    print(sum(items))
    print(*items)



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts()
    # 全部の合計は1の倍数の箱の個数
    o1 = sum(A)
    ans = []
    if o1 % 2 == 1:
        ans.append(1)
    else:
        ans.append(0)
    for i in range(n):
        a = i+1
        s_ = sum(A[i+1::a])
        if s_ == 0:
            ans.append(0)
        else:
            if s_ % 2 == 1:
                ans.append(1)
            else:
                ans.append(0)
    m = sum(ans)
    if m == 0:
        print(0)
    else:
        print(m)
        for i in range(n):
            if ans[i] != 0:
                print(i+1,end =" ")
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts()
    # 全部の合計は1の倍数の箱の個数
    o1 = sum(A)
    ans = []
    if o1 % 2 == 1:
        ans.append(1)
    else:
        ans.append(0)
    for i in range(n):
        a = i+1
        s_ = sum(A[i+1::a])
        if s_ == 0:
            ans.append(0)
        else:
            if s_ % 2 == 1:
                ans.append(1)
            else:
                ans.append(0)
    m = sum(ans)
    if m == 0:
        print(0)
    else:
        print(m)
        for i in range(n):
            if ans[i] != 0:
                print(ans[i],end =" ")
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    B = []
    for i in reversed(range(1, n + 1)):
        k = i
        cnt = 0
        while k <= n:
            cnt += A[k]
            k += i

        if cnt % 2 != 0:
            A[i] += 1
            B.append(1)

    print(sum(B))
    print(*B[::-1])


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")



def main():
    n = int(input())
    A = list(map(int, input().split()))
    cnt = [0] * n
    B = deque([])
    for i in range(n-1, -1, -1):
        if sum(cnt[i::i+1]) % 2 == A[i]:
            continue
        else:
            cnt[i] += 1
    print(cnt)
    ans = []
    for i, v in enumerate(cnt):
        if v > 1:
            print(-1)
            exit()
        elif v == 1:
            ans.append(i+1)
        else:
            continue
    if len(ans) == 0:
        print(len(ans))
    else:
        print(len(ans))
        print(*ans)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc134/tasks/abc134_d
# 偶奇だけが重要
# 後半は即座に決定できる(倍数が存在しないので)
# 後ろから決定できない？
# nの倍数の個数を更新していく

N = read_a_int()
A = read_ints()

ans = [0] * N
ans[N // 2:] = A[N // 2:]
for i in ra(N // 2 - 1, -1, -1):
    # (i+1)の倍数の個数の集計
    n = i + 1
    s = sum(ans[n::n]) % 2
    ans[i] = s ^ A[i]

print(sum(ans))
ans_pr = []
for i, v in enu(ans, start=1):
    if v:
        ans_pr.append(i)
print(*ans_pr)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


def resolve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    B = []
    for i in reversed(range(1, n + 1)):
        k = i
        cnt = 0
        while k <= n:
            cnt += A[k - 1]
            k += i

        if cnt % 2 != 0:
            A[i] += 1
            B.append(1)

    print(sum(B))
    print(*B[::-1])


if __name__ == '__main__':
    resolve()

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):
    #i+1>=N//2+1
    if i>=N//2:
        ball[i]=A[i]
    else:
        now=0
        n=2
        while (i+1)*n-1<N:
            now+=ball[(i+1)*n-1]
            n+=1
        if now%2!=A[i]:
            ball[i]=1
print(sum(ball))
for b in ball:
    if b!=0:
        print(b, end=" ")

Submission status: Wrong Answer

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


    def divisors(n):
        ret = set()
        for i in range(1, int(n**0.5) + 1):
            if n % i == 0:
                ret.add(i)
                ret.add(n//i)

        return(ret)


    ans = set()
    for i in range(N-1, -1, -1):
        a[i] %= 2
        if a[i]:
            for j in divisors(i):
                a[j-1] += 1
            ans.add(i+1)

    print(len(ans))

    print(*ans)
main()

Submission status: Wrong Answer

Solution code:
def resolve():
    import math
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    ans[math.floor(n/2):n] = a[math.floor(n/2):n]
    if n == 1:
        print(a[0])
        print(a[0])
    else:
        for i in range(math.floor(n/2)-1, 0, -1):
            sumi = 0
            for j in range(i, n, i+1):
                sumi += ans[j]
                sumi %= 2
            if sumi == a[i]:
                ans[i] = 0
            else:
                ans[i] = 1
        if a[0] == sum(ans)%2:
            ans[0] = 0
        else:
            ans[0] = 1
        ansl = []
        for i, j in enumerate(ans):
            if j == 1:
                ansl.append(i+1)
        print(len(ansl))
        if len(ansl)!= 0:
            print(" ".join(map(str, ansl)))
resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    import math
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    ans[math.floor(n/2):n] = a[math.floor(n/2):n]
    if n == 1:
        print(a[0])
    else:
        for i in range(math.floor(n/2)-1, 0, -1):
            sumi = 0
            for j in range(i, n, i+1):
                sumi += ans[j]
                sumi %= 2
            if sumi == a[i]:
                ans[i] = 0
            else:
                ans[i] = 1
        if a[0] == sum(ans)%2:
            ans[0] = 0
        else:
            ans[0] = 1
        ansl = []
        for i, j in enumerate(ans):
            if j == 1:
                ansl.append(i+1)
        print(len(ansl))
        if len(ansl)!= 0:
            print(" ".join(map(str, ansl)))
resolve()

Submission status: Wrong Answer

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


def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            ret.add(i)
            ret.add(n//i)

    return(ret)


ans = [0]*N
for i in range(N-1, -1, -1):
    a[i] %= 2
    if a[i]:
        for j in divisors(i):
            a[j-1] += 1
        ans[i] = 1
S = sum(ans)
print(S)
if S:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
B = [0] * N # 入っている箱 0 1 0 1とか
wa = 0
tmp = 0
for i in range(N, 0, -1):
    tmp = 0
    for j in range(i, N+1, i):
        if i == j:
            continue
        else:
            # print(j)
            tmp ^= A[j-1]
    # print("*****")
    if tmp == A[i-1]:
        B[i-1] = 0
    else:
        B[i-1] = 1
# print(B)
M = sum(B)
if M == 0:
    print(M)
    exit()
else:
    print(M)
    for i, b in enumerate(B):
        if b == 1:
            print(i+1, end=" ")
    print()

Submission status: Wrong Answer

Solution code:

def resolve():
    import math
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    ans[math.floor(n/2):n] = a[math.floor(n/2):n]
    for i in range(math.floor(n/2)-1, 0, -1):
        sumi = 0
        for j in range(i, n, i+1):
            sumi += ans[j]
            sumi %= 2
        if sumi == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1
    if a[0] == sum(ans)%2:
        ans[0] = 0
    else:
        ans[0] = 1
    ansl = []
    for i, j in enumerate(ans):
        if j == 1:
            ansl.append(i+1)
    print(len(ansl))
    if len(ansl)!= 0:
        print(" ".join(map(str, ansl)))
resolve()

Submission status: Wrong Answer

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

ans=[0 for i in range(n)]
for i in range(n-1,-1,-1):
  if i+1>n//2:
    ans[i]=a[i]
    continue

  t_sum=sum(ans[i+1::i+1])
  if t_sum%2==a[i]:
    ans[i]=0
  else:
    ans[i]=1

cnt=ans.count(1)
print(cnt)
if cnt!=0:
  print(*[i+1 for i in range(n) if ans[i]==1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0]+list(map(int,input().split()))
ans = [-1]*(n+1)
for i in range(n,0,-1):
    res = 0
    for j in range(i+i,n+1,i):
        res += ans[j]
    ans[i] = a[i]-(res%2)
p = []
for ind,v in enumerate(ans):

    if v== -1:continue
    if v == 1:p.append(ind)

print(len(p))
print(*p)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0]+list(map(int,input().split()))
ans = [-1]*(n+1)
for i in range(n,0,-1):
    res = 0
    for j in range(i+i,n,i):
        res += ans[j]
    ans[i] = a[i]-(res%2)
p = []
for ind,v in enumerate(ans):

    if v== -1:continue
    if v == 1:p.append(ind)

print(len(p))
print(*p)

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
  cnt = 0
  for j in range(1, N//i):
    cnt += afterA[j*i-1]
  if(cnt % 2 != A[i-1]):
    afterA[i-1] = 1 
    ans.append(i)
  
print(sum(A))
print(*ans)

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
  cnt = 0
  for j in range(1, N//i):
    cnt += A[j*i-1]
  if(cnt % 2 == 1):
    ans.append(i)
  
print(sum(A))
print(*ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
idx = np.array([i+1 for i in range(n)])

if a.sum() == 0:
  print(0)
else:
  ans = -1
  val1_idx = idx[a==1]
  for i in range(1, n+1):
    ball_pos = val1_idx%i == 0
    sum_ball = ball_pos.sum()
    if a[i-1] == sum_ball%2:
      ans = i
      break
  if ans == -1:
    print(-1)
  else:
    if sum_ball == 0:
      print(0)
    else:
      print(sum_ball)
      for i in val1_idx[ball_pos]:
        print(i, end=' ')

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
idx = np.array([i+1 for i in range(n)])

if a.sum() == 0:
  print(0)
else:
  ans = -1
  val1_idx = idx[a==1]
  for i in range(1, n+1):
    ball_pos = val1_idx%i == 0
    sum_ball = ball_pos.sum()
    if a[i-1] == sum_ball%2:
      ans = i
      break
  if ans == -1:
    print(-1)
  else:
    if sum_ball == 0:
      print(0)
    else:
      print(sum_ball)
      for i in val1_idx[ball_pos]:
        print(i)

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    B = [0 for _ in range(N)]
    for i in range(N - 1, N // 2 - 1, -1):
        B[i] = A[i]
    for i in range(N // 2 - 1, -1, -1):
        res = 0
        for j in range(i, N, i + 1):
            res += B[j]
        if res % 2 == 0 and A[i] == 1:
            B[i] = 1
        elif res % 2 != 0 and A[i] == 0:
            B[i] = 1

    cnt = 0
    for b in B:
        if b == 1:
            cnt += 1
    print(cnt)
    if cnt > 0:
        res = [b for b in B if b != 0]
        print(*res)

Submission status: Wrong Answer

Solution code:
n = int(input())
ns = list(map(int, input().split()))
rslt = [0] * n
r = n - 1 
while r >= 0:
    if sum(rslt[r:n:r+1]) % 2 == ns[r]:
        rslt[r] += 1
    r -= 1
print(sum(ns))
if sum(ns):
    print(*[i+1 for i, num in enumerate(ns) if num == 1])

Submission status: Wrong Answer

Solution code:
#Coding:Utf-8

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

check=[0 for i in range(N)]
M=0
b=[]
for j in reversed(range(N)):
    total=0
    for k in range(1,int(N/(j+1))):
        total+=check[int((j+1)/k)-1]
    if a[j]!=total:
        M+=1
        check[j]=1
        b.append(j+1)

print(M)
for l in range(len(b)):
    print(b[l],end='')
else:
    print()

Submission status: Wrong Answer

Solution code:
#Coding:Utf-8

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

check=[0 for i in range(N)]
M=0
b=[]
for j in reversed(range(N)):
    total=0
    for k in range(1,int(N/(j+1))):
        total+=a[int(j/k)]
    if a[j]!=total:
        M+=1
        check[j]=1
        b.append(j+1)

print(M)
for l in range(len(b)):
    print(b[l],end='')

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
b = [0]*(N+1)
a = [0] + a
for i in range(N, 0, -1):
  tmp = 0
  for j in range(1, N//i+1):
    tmp += b[i*j]
  tmp %= 2
  if a[i] == tmp:
    continue
  elif a[i] == 1 and tmp == 0:
    b[i] += 1
  elif a[i] == 0 and tmp == 1:
    print('-1')
    exit()
  
M = 0
for i in range(1, N+1):
  if b[i] == 1:
    M += 1
print(M)
for i in range(1, N+1):
  if b[i] == 1:
    print(i, end=" ")

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
b = [0]*(N+1)

def divisor(n):
  res = []
  for i in range(1, int(math.sqrt(n))+1):
    if n % i == 0:
      res += [i]
      b[i] += 1
      if n // i != i:
        b[n//i] += 1
        res += [n//i]
  # print("n: ", n, "res: ", res)


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


M = 0
for i in range(1, N+1):
  if b[i] != 0 and b[i] % 2 != 0:
    M += 1
print(M)
for i in range(1, N+1):
  if b[i] != 0 and b[i] % 2 != 0:
    print(i, end=" ")

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
b = [0]*(N+1)

def divisor(n):
  res = []
  for i in range(1, int(math.sqrt(n))+1):
    if n % i == 0:
      res += [i]
      b[i] += 1
      if n // i != i:
        b[n//i] += 1
        res += [n//i]
  # print("n: ", n, "res: ", res)


for i in range(N-1, -1, -1):
  if a[i] != b[i+1]:
    divisor(i+1)

M = 0
for i in range(1, N+1):
  if b[i] != 0 and b[i] % 2 != 0:
    M += 1
print(M)
for i in range(1, N+1):
  if b[i] != 0 and b[i] % 2 != 0:
    print(i, end=" ")

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
b = [0]*(N+1)

def divisor(n):
  res = []
  for i in range(1, int(math.sqrt(n))+1):
    if n % i == 0:
      res += [i]
      b[i] += 1
      if n // i != i:
        b[n//i] += 1
        res += [n//i]
  # print("n: ", n, "res: ", res)


for i in range(N-1, -1, -1):
  if a[i] != b[i+1]:
    divisor(i+1)

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans = [0 for i in range(n+1)]
    for i in range(n):
        s = 0
        k = n-i
        for j in range(1,n//k+1):
            s += ans[k*j]
        if s%2!=a[k-1]:
            ans[k] = 1
    print(sum(ans))
    if sum(ans)!=0:
        print(''.join([str(i) for i , x in enumerate(ans) if x==1]))



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(i) for i in input().split()]

box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
    ball = nums[i - 1]
    t = i * 2
    while t <= n:
        ball ^= box[i - 1]
        t += i
    box[i - 1] = ball

ans = box.count(1)
index = []
for i in range(len(box)):
    if box[i]:
        index.append(i)
print(ans)
print(*index)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(i) for i in input().split()]

box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
    ball = nums[i - 1]
    t = i * 2
    while t <= n:
        ball ^= box[i]
        t += i
    box[i] = ball

ans = box.count(1)
index = []
for i in range(len(box)):
    if box[i]:
        index.append(i)
print(ans)
print(*index)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(i) for i in input().split()]

box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
    ball = nums[i - 1]
    t = i
    while t <= n:
        ball ^= box[i]
        t += i
    box[i] = ball

ans = box.count(1)
index = []
for i in range(len(box)):
    if box[i]:
        index.append(i)
print(ans)
print(*index)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(i) for i in input().split()]

box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
    ball = nums[i - 1]
    box[i] = ball
    t = i
    while t <= n + 1:
        ball ^= box[i]
        t += i
    box[i] = ball

ans = box.count(1)
index = []
for i in range(len(box)):
    if box[i]:
        index.append(i)
print(ans)
print(*index)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(i) for i in input().split()]

box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
    ball = nums[i - 1]
    box[i] = ball
    t = i
    while t <= n + 1:
        if box[i] & 1:
            box[i] = ball
        t += i

ans = box.count(1)
index = []
for i in range(len(box)):
    if box[i]:
        index.append(i)
print(ans)
print(*index)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
a = list(map(int, sys.stdin.readline().split()))
box = [0] * N
if N % 2 == 0:
    half = N // 2 - 1
else:
    half = N // 2
    
ball_count = 0
ball_box = []

for i in range(N - 1, -1, -1):
    if i >= half:
        if a[i] == 1:
            box[i] = 1
            ball_count += 1
            ball_box.append(i + 1)
    else:
        m = N // (i + 1)
        count = 0
        for j in range(1, m + 1):
            count += box[(i + 1) * j - 1]
            count %= 2
        if a[i] != count:
            box[i] = 1
            ball_count += 1
            ball_box.append(i + 1)
            
print(ball_count)
ball_box = [str(ball_box[i]) for i in range(ball_count - 1, -1, -1)]
box_ans = " ".join(ball_box)
print(box_ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n-1, -1, -1):
    if sum(a[i:n:i+1])%2==1:
        a[i]+=1
        ans.append(i+1)
a.sort()
print(len(ans))
print(*ans)