Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


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]


# 実装を行う関数
def resolve(test_def_name=""):
    m = int(input())
    b_s = list(map(int, input().split()))

    divisors = [[0]] + [make_divisors(i) for i in range(1, m + 1)]
    ans = [0] + [0 for i in range(1, m + 1)]
    count = [0] + [0 for i in range(1, m + 1)]

    for num, b in reversed(list(enumerate(b_s, start=1))):
        if (b == 1 and count[b] % 2 == 0) or (b == 0 and count[b] % 2 != 0):
            for div in divisors[num]:
                count[div] += 1

        if count[b] % 2 != 0:
            ans[num] = 1

    # 結果比較
    ans = ans[1:]
    if b_s != ans:
        print(-1)
        return

    print(ans.count(1))
    for cnt, i in enumerate(ans, start=1):
        if i == 1:
            print(cnt)

    # テストクラス


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
1 0 0"""
        output = """1
1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5
0 0 0 0 0"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """5
0 0 0 0 1"""
        output = """1
5"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """5
0 1 0 1 0"""
        output = """1
4"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


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]


# 実装を行う関数
def resolve(test_def_name=""):
    m = int(input())
    b_s = list(map(int, input().split()))

    divisors = [[0]] + [make_divisors(i) for i in range(1, m + 1)]
    ans = [0] + [0 for i in range(1, m + 1)]
    count = [0] + [0 for i in range(1, m + 1)]

    for num, b in reversed(list(enumerate(b_s, start=1))):
        if (b + count[b]) % 2 == 0:
            pass
        else:
            ans[num] = 1
            for div in divisors[num]:
                count[div] += 1

    # 結果比較
    ans = ans[1:]
    if b_s != ans:
        print(-1)

    print(ans.count(1))
    for cnt, i in enumerate(ans, start=1):
        if i == 1:
            print(cnt)

    # テストクラス


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
1 0 0"""
        output = """1
1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5
0 0 0 0 0"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """5
0 0 0 0 1"""
        output = """1
5"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


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]


# 実装を行う関数
def resolve(test_def_name=""):
    m = int(input())
    b_s = list(map(int, input().split()))

    divisors = [[0]] + [make_divisors(i) for i in range(1, m + 1)]
    ans = [0] + [0 for i in range(1, m + 1)]
    count = [0] + [0 for i in range(1, m + 1)]

    for num, b in reversed(list(enumerate(b_s, start=1))):
        if (b + count[b]) % 2 == 0:
            pass
        else:
            ans[b] = 1
            for div in divisors[num]:
                count[div] += 1

    # 結果比較
    ans = ans[1:]
    if b_s != ans:
        print(-1)

    print(ans.count(1))
    for cnt, i in enumerate(ans, start=1):
        if i == 1:
            print(cnt)

    # テストクラス


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
1 0 0"""
        output = """1
1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5
0 0 0 0 0"""
        output = """0"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

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

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

ans = []
for i, x in enumerate(b):
	if 0 < x:
		ans.append(i)

if ans:
	print(*ans)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

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

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

for i in range(1, N+1):
	tmp = 0
	for j in range(N//i, 0, -1):
		k = i * j
		if (b[k] + tmp)%2 == a[k]:
			tmp += b[k]
		else:
			print(-1)
			break
	else:
		continue
	break
else:
	print(*[ans for ans, B in enumerate(b) if 0 < B])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = [0] + A
d = [0 for _ in range(N+1)]

for i in reversed(range(1, N+1)):
    if i <= N//2:
        d[i] = A[i]
    else:
        k = i // 2
        temp = 0
        for j in range(2, k+1):
            if j*i > N:
                break
            temp += A[j*i]
        if temp % 2 == 1 and A[i] == 1:
            d[i] = 0
        elif temp % 2 == 1 and A[i] == 0:
            d[i] = 1
        elif temp % 2 == 0 and A[i] == 1:
            d[i] = 1
        else:
            d[i] = 0

print(d.count(1))
for el in d:
    if el == 1:
        print(el, end=" ")

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

B = [-1 for _ in range(N)]
ans = []

for i in range(N, 0, -1):
    tmp_sum = 0
    if N % i == 0 and N // i > 1:
        multi_max = N // i
        c = 1
        while multi_max > c:
            c += 1
            tmp_sum += B[c * i - 1]

    # print(i, tmp_sum)
    if A[i-1] == 1:
        if tmp_sum % 2 == 0:
            ans.append(i)
            B[i-1] = 1
        else:
            B[i-1] = 0
    else:
        if tmp_sum % 2 == 0:
            B[i-1] = 0
        else:
            ans.append(i)
            B[i-1] = 1

print(len(ans))
if len(ans):
    print(" ".join(map(str, ans[::-1])))

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

ans = [-1 for _ in range(N)]

count = 0
for i in range(N, 0, -1):
    tmp_sum = 0
    if N % i == 0 and N // i > 1:
        multi_max = N // i
        c = 1
        while multi_max > c:
            c += 1
            tmp_sum += ans[c * i - 1]

    # print(i, tmp_sum)
    if A[i-1] == 1:
        if tmp_sum % 2 == 0:
            count += 1
            ans[i-1] = 1
        else:
            ans[i-1] = 0
    else:
        if tmp_sum % 2 == 0:
            ans[i-1] = 0
        else:
            count += 1
            ans[i-1] = 1

print(count)
if count:
    print(" ".join(["1"] * count))

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

ans = [-1 for _ in range(N)]

count = 0
for i in range(N, 0, -1):
    tmp_sum = 0
    if N % i == 0 and N // i > 1:
        multi_max = N // i
        c = 1
        while multi_max > c:
            c += 1
            tmp_sum += A[c * i - 1]

    # print(i, tmp_sum)
    if A[i-1] == 1:
        if tmp_sum % 2 == 0:
            count += 1
            ans[i-1] = 1
        else:
            ans[i-1] = 0
    else:
        if tmp_sum % 2 == 0:
            ans[i-1] = 0
        else:
            count += 1
            ans[i-1] = 1

print(count)
if count:
    print(" ".join(["1"] * count))

Submission status: Wrong Answer

Solution code:
def m():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    X = [0] * (N+1)
    for i in range(N, 0,-1):
        p = 0
        for j in range(i, N, i):
            if X[j]: p +=1
        if p % 2 != A[i]:
            X[i] = 1
    M = X.count(1)
    print(M)
    for i in range(1, N+1):
        if X[i] == 0:
            continue
        print(i, end='')
    return

m()

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

ans = [-1 for _ in range(N)]

for i in range(N, 0, -1):
    tmp_sum = 0
    if N % i == 0 and N // i > 1:
        multi_max = N // i
        c = 1
        while multi_max > c:
            c += 1
            tmp_sum += A[c * i - 1]

    # print(i, tmp_sum)
    if A[i-1] == 1:
        if tmp_sum % 2 == 0:
            ans[i-1] = 1
        else:
            ans[i-1] = 0
    else:
        if tmp_sum % 2 == 0:
            ans[i-1] = 0
        else:
            ans[i-1] = 1

print(*ans)

Submission status: Wrong Answer

Solution code:
#create date: 2020-07-07 11:19

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = [0] * n
    
    for i in range(n, 0, -1):
        cnt = 0
        m = i
        while m <= n:
            if b[m-1] == 1:
                cnt += 1
            m += i
        if cnt == a[i-1]:
            continue
        elif cnt + 1 == a[i-1]:
            b[i-1] = 1
        else:
            print(-1)
            quit()
    #print(b)
    print(sum(b))
    for i, bi in enumerate(b):
        if bi == 1:
            print(i+1, end=" ")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#create date: 2020-07-07 11:19

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = [0] * n
    for i in range(n, 0, -1):
        cnt = 0
        for j in range(1, n+1):
            if j // i == 0:
                cnt += b[j-1]
        
        if cnt == a[i-1]:
            continue
        elif cnt + 1 == a[i-1]:
            b[i-1] = 1
        else:
            print(-1)
            quit()
    #print(b)
    for i, bi in enumerate(b):
        if bi == 1:
            print(i+1)
    if sum(b) == 0:
        print(0)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0 for i in range(n+1)]
c = 0
for i in range(n, 0, -1):
  s = a[i]
  for j in range(2,n//i+1):
    s += b[j*i]
  if s %2 != 1:
    c += 1
    b[i] = 1
print (c)
a2 = []
for i in range(n):
  if b[i] == 1: 
    a2.append(i+1)
print (*a2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0 for i in range(n+1)]
c = 0
for i in range(n, 0, -1):
  s = a[i]
  for j in range(2,n//i+1):
    s += b[j*i]
  if s %2 != 1:
    c += 1
    b[i] = 1
print (c)
for i in range(n+1):
  if b[i] == 1:
    print (i)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
    if totals[i]%2==a[i]:
        continue
    else:
        ans[i]+=1
        tmp=1
        while tmp*tmp<=i+1:
            if n%tmp==0:
                totals[tmp-1]+=1
                if tmp !=(i+1)//tmp:
                    totals[((i+1)//tmp)-1]+=1

            tmp+=1


cnt=ans.count(1)

print(cnt)
if cnt!=0:
    b=[]
    for j in range(n):
        if ans[j]!=0:
            b.append(j+1)

    print(*b)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
    if totals[i]%2==a[i]:
        continue
    else:
        ans[i]+=1
        tmp=1
        while tmp*tmp<i+1:
            if n%tmp==0:
                totals[tmp-1]+=1
                if tmp !=(i+1)//tmp:
                    totals[((i+1)//tmp)-1]+=1

            tmp+=1


cnt=ans.count(1)

print(cnt)
if cnt!=0:
    b=[]
    for j in range(n):
        if ans[j]!=0:
            b.append(j+1)

    print(*b)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
    if totals[i]%2==a[i]:
        continue
    else:
        ans[i]+=1
        tmp=1
        while tmp*tmp<i+1:
            if n%tmp==0:
                totals[(n//tmp)-1]+=1
                totals[tmp-1]+=1

            tmp+=1


cnt=ans.count(1)

print(cnt)
if cnt!=0:
    b=[]
    for j in range(n):
        if ans[j]!=0:
            b.append(j+1)

    print(*b)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
    if totals[i]%2==a[i]:
        continue
    else:
        ans[i]+=1
        tmp=1
        while tmp<(i+1)**0.5:
            if n%tmp==0:
                totals[(n//tmp)-1]+=1
                totals[tmp-1]+=1

            tmp+=1


cnt=ans.count(1)

print(cnt)
if cnt!=0:
    b=[]
    for j in range(n):
        if ans[j]!=0:
            b.append(j+1)

    print(*b)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int, input().split()))
b = np.zeros(N, dtype='int')

flag = 1
for i in range(int(N/2)+1, N+1, 1):
  b[i-1] = a[i-1]
#print(b)
#for i in range(0, int(N/2)+1, 1):
for i in range(int(N/2), 0, -1):
  tmp = a[i-1]
  j = i+i
  while j < N+1:
    tmp += b[j-1]
    j += (i+i)
  if tmp % 2 == a[i-1]:
    b[i-1] = a[i-1]
  else:
    flag = 0
    break
if flag == 0:
  print(-1)
else:
  print(sum(b))
  out = []
  for i in range(N):
    if b[i] != 0:
      out.append(i+1)
  print(*out)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int, input().split()))
b = np.zeros(N, dtype='int')

flag = 1
for i in range(int(N/2)+1, N+1, 1):
  b[i-1] = a[i-1]
#print(b)
#for i in range(0, int(N/2)+1, 1):
for i in range(int(N/2), 0, -1):
  tmp = a[i-1]
  j = i+i
  while j < N+1:
    tmp += b[j-1]
    j += (i+i)
  if tmp % 2 == a[i-1]:
    b[i-1] = a[i-1]
  else:
    flag = 0
    break
if flag == 0:
  print(-1)
else:
  print(sum(b))
  b = [1]*sum(b)
  print(*b)

Submission status: Wrong Answer

Solution code:
m=int(input())
b=list(map(int,input().split()))
ans=[]
for i in range(m-1,-1,-1):
    t=i+1
    tmp=0
    for j in range(1,m//t):
        k=t*j
        if k in ans:
            tmp^=1
    if tmp!=b[i]:
        ans.append(i)
print(len(ans))
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int,input().split())), dtype=int)
b = np.zeros(n, dtype=int)

for i in range(n-1, -1, -1):
    m = sum(b[i::i+1]) % 2
    b[i] = (a[i] + m) % 2
bsum =sum(b) 
if bsum == 0:
    print(bsum)
else:
    ans = b.astype('str')
    print(bsum)
    print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[]
dp=[0]*(N+1)
ans=0
for i in range(N,0,-1):
  for j in range(1,N//i+1):
    dp[i]+=dp[j*i]%2
  if dp[i]%2!=a[i-1]:
    dp[i]=dp[i]%2+1
    ans+=1
    b.append(i)
b.sort()
print(ans)
print(*b)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[]
dp=[0]*(N+1)
ans=0
for i in range(N,0,-1):
  for j in range(1,N//i+1):
    dp[i]+=dp[j*i]
  if dp[i]%2!=a[i-1]:
    dp[i]+=1
    ans+=1
    b.append(i)
b.sort()
print(ans)
print(*b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

box = np.array([False] * (N+1))

for i in range(1, N+1):
    tmp = A[i-1]
    if tmp == 1:
        if not box[i]:
            box[i::i] = ~box[i::i]
    else:
        if box[i]:
            box[i::i] = ~box[i::i]

box = box.tolist()
print(sum(box))

for i, b in enumerate(box):
    if b:
        print(i, end=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0]+list(map(int,input().split()))
b = [0]*(n+1)
for i in range(n,0,-1):
    b_sum = sum([b[i*j] for j in range(1,n//i+1)])
    b_sum %= 2
    if a[i] == 1 and b_sum == 0:
        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+1)
for i in range(n,0,-1):
    b_sum = sum([b[i*j] for j in range(1,n//i)])
    b_sum %= 2
    if a[i] == 1 and b_sum == 0:
        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:
import numpy as np

n = int(input())
A = np.array(list(map(int,input().split())))

balls = np.array([0]*(n+1))

for i in range(1,n+1):
    s = sum(balls[i::i])
    if s%2 != A[-i]:
        balls[-i] += 1

ans = np.where(balls==1)[0].tolist()
if sum(balls):
    print(sum(balls))
    print(*ans)
else:
    print(0)

Submission status: Wrong Answer

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

al = [0] + al # 1-index
multi_cnts = [0]*(N+1)
ans = []
for n in range(N,0,-1):
    if multi_cnts[n] != al[n]:
        ans.append(n)
        for i in range(1, int(-(-n**0.5//1))+1):
            if n%i == 0:
                multi_cnts[i]+=1
                multi_cnts[i]%=2
                if i*i != n:
                    multi_cnts[n//i]+=1
                    multi_cnts[n//i]%=2


print(len(ans))
if ans: print(*ans)

Submission status: Wrong Answer

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

al = [0] + al # 1-index
multi_cnts = [0]*(N+1)
ans = []
for n in range(N,0,-1):
    if multi_cnts[n] != al[n]:
        ans.append(n)
        for i in range(1, int(-(-n**0.5//1))+1):
            if n%i == 0:
                multi_cnts[i]+=1
                multi_cnts[i]%=2
                multi_cnts[n//i]+=1
                multi_cnts[n//i]%=2


print(len(ans))
if ans: print(*ans)

Submission status: Wrong Answer

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

print(-1)
exit()

al = [0] + al # 1-index
multi_cnts = [0]*(N+1)
ans = []
for n in range(N,0,-1):
    if multi_cnts[n] != al[n]:
        ans.append(n)
        for i in range(2, int(-(-n**0.5//1))+1):
            if n%i == 0:
                multi_cnts[i]+=1
                multi_cnts[i]%=2


print(len(ans))
if ans: print(*ans)

Submission status: Wrong Answer

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

al = [0] + al # 1-index
multi_cnts = [0]*(N+1)
ans = []
for n in range(N,0,-1):
    if multi_cnts[n] != al[n]:
        ans.append(n)
        for i in range(2, int(-(-n**0.5//1))+1):
            if n%i == 0:
                multi_cnts[i]+=1
                multi_cnts[i]%=2


print(len(ans))
if ans: print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
decided = [0 for _ in range(N+1)]

a.insert(0,0)

for i in range(N,0,-1):
    count = 0
    check = 2*i
    while check <= N:
        count = (count+decided[check])%2
        check += i
    if a[i] == 1 and count == 1:
        continue
    elif a[i] == 0 and count ==0:
        continue
    else:
        decided[i] = 1

print(sum(decided))
answer = [i for i in range(N+1) if decided[i]==1]

print("".join(list(str(i) for i in answer)))

Submission status: Wrong Answer

Solution code:
from collections import deque
N = int(input())
a = list(map(int, input().split()))
b = deque()
ans = 0

for i in range(N):
  t = N-1-i
  s = 0
  while t < N:
    if t+1 in b:
      s += 1
    t += i+1
  if (a[N-1-i]+s) % 2 == 1:
    b.appendleft(N-i)
    ans += 1
    
print(ans)
print(' '.join(map(str, b)))

Submission status: Wrong Answer

Solution code:
from collections import deque
N = int(input())
a = list(map(int, input().split()))
b = deque()
ans = 0

for i in range(N):
  t = N-1-i
  if (a[t]+ans) % 2 == 1:
    b.appendleft(N-i)
    ans += 1
    
print(ans)
print(' '.join(map(str, b)))

Submission status: Wrong Answer

Solution code:
from collections import deque
N = int(input())
a = list(map(int, input().split()))
b = deque()
ans = 0

for i in range(N):
  t = N-1-i
  s = 0
  while t < N:
    s += a[t]
    t += i+1
  if s % 2 == 1:
    b.append(N-i)
    ans += 1
    
print(ans)
print(' '.join(map(str, b)))

Submission status: Wrong Answer

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

for i in range(N):
    Res[N-i] = A[N-i] ^ (sum(Res[::N-i]) % 2)

print(sum(Res))
ResN = []
for i,r in enumerate(Res):
    if i==0:
        continue
    if r == 1:
        ResN.append(str(i))

if ResN:
    print(''.join(ResN))

Submission status: Wrong Answer

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

for i in range(N):
    Res[N-i] = A[N-i] ^ (sum(Res[::N-i])%2)

print(sum(Res))
ResN = []
for i,r in enumerate(Res):
    if r == 1:
        ResN.append(str(i))

if ResN:
    print(''.join(ResN))

Submission status: Wrong Answer

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


searchedMax = N
ans = 0
while searchedMax>=1:
    half = int(searchedMax/2)+1
    #ans += sum(A[half:searchedMax])
    for i,a in enumerate(A[half:searchedMax+1]):
        ind = i+half
        ans += a
        if ind%2 == 0:
            A[int(ind/2)] -= a
        if a<0:
            print(-1)
            exit()
    searchedMax = half-1

print(ans)
print(''.join(['1']*ans))

Submission status: Wrong Answer

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


searchedMax = N
ans = 0
while searchedMax>=1:
    half = int(searchedMax/2)+1
    #ans += sum(A[half:searchedMax])
    for i,a in enumerate(A[half:searchedMax+1]):
        ind = i+half
        ans += a
        A[int(ind/2)] -= a
        if a<0:
            print(-1)
            exit()
    searchedMax = half-1

print(ans)
print(''.join(['1']*ans))

Submission status: Wrong Answer

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

cnt = [0]*200010

b = []

for i in reversed(range(n)):

	if cnt[i]%2 != a[i]:
		b.append(i+1)
		cnt[i] += 1
		j = 1
		while j*j < (i+1):
			if (i+1)%j==0 :
				cnt[j-1] += 1
				if i/j != j:
					cnt[(i+1)//j -1]+=1
			j = j +1

print(len(b))
b.sort()

for i in b:
	print(str(i)+' ',end='')

print()

Submission status: Wrong Answer

Solution code:
from collections import deque
n =int(input())
a = [0]+list(map(int, input().split()))
d = deque()
cnt=0
for i in range(n,0,-1):    
  for j in range(i,n+1,i):
    if a[j]==0:
      continue
    cnt+=1
  b = cnt%2
  a[i] = b
  if b == 1:
    d.appendleft(i)
  cnt = 0
if len(d) == 0:
  print(0)
else:
  print(' '.join(map(str,d)))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ret = []
for i in range(n):
  count = A[i]
  num = i + 1
  while True:
    num += (i + 1)
    if num > n:
      break
    count += A[num - 1]
  if count % 2:
    ret.append(i + 1)

if ret:
  print(len(ret))
  print(*ret)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ret = []
for i in range(n):
  count = A[i]
  num = i + 1
  while True:
    num += (i + 1)
    if num > n:
      break
    count += A[num - 1]
  if count % 2:
    ret.append(i + 1)
print(len(ret))
print(*ret)