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 math as math

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
for i in range(math.ceil(N/2),N):
    ANS[i] = A[i]

fnum=math.floor(N/2)-1
for i in range(fnum,-1,-1):
    j = i + 1
    tsum=A[i]
    for k in range(j,N+1,j):
        tsum+=ANS[k-1]
    ANS[i]=tsum%2

#print(ANS)
anslist=[]
for i in range(N):
    if ANS[i]==1:
        anslist.append(i+1)
 
print(len(anslist))
for s in anslist:
    print(s, end =" ")

Submission status: Wrong Answer

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

    return divisors

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)

ansList = []
for i in range(len(A),1,-1):
    if(ANS[i-1]%2!=A[i-1]):
        tList = make_divisors(i)
        #print(tList)
        for j in tList:
            ANS[j-1]+=1
        ANS[i-1]+=1
        ansList.append(i)


if(len(ansList)%2!=0):
    ANS[0]+=1
    ansList.append(1)


print(len(ansList))
for i in ansList:
    print(i, end=" ")

Submission status: Wrong Answer

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

    return divisors

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)

ansList = []
for i in range(len(A),1,-1):
    if(ANS[i-1]%2!=A[i-1]):
        tList = make_divisors(i)
        #print(tList)
        for j in tList:
            ANS[j-1]+=1
        ansList.append(i)


if(len(ansList)%2!=0):
    ANS[0]+=1
    ansList.append(1)


print(len(ansList))
for i in ansList:
    print(i, end=" ")

Submission status: Wrong Answer

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

    return divisors

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)

ansList = []
for i in range(len(A),1,-1):
    if(ANS[i-1]%2!=A[i-1]):
        tList = make_divisors(i)
        print(tList)
        for j in tList:
            ANS[j-1]+=1
        ansList.append(i)


if(len(ansList)%2!=0):
    ANS[0]+=1
    ansList.append(1)


print(len(ansList))
for i in ansList:
    print(i, end=" ")

Submission status: Wrong Answer

Solution code:
#D
N = int(input()) 
box = [0] * N 
for i in range(N-1, 0, -1):
    aisum = 0 
    for j in range(i, N, i):
        aisum += box[j] 
    if aisum%2 == 0: 
        box[i] = 1 
    else: 
        box[i] = 0 
print(' '.join(map(str, box)))

Submission status: Wrong Answer

Solution code:
#D
N = int(input()) 
box = [0] * N 
for i in range(N-1, 0, -1):
    aisum = 0 
    for j in range(i, N, i):
        aisum += box[j] 
    if aisum%2 == 0: 
        box[i] = 1 
    else: 
        box[i] = 0 
print(' '.join(map(str, box[::-1])))

Submission status: Wrong Answer

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

ok = True
res = [0] * N
for i in range(N):
    j = N - i
    m = int(N / j)
    s = sum([res[j*k-1] for k in range(2, m+1)])
    if As[j-1] - s > 1:
        ok = False
        break
    res[j-1] = As[j-1] - s

if ok:
    Bs = [i+1 for i in range(len(res)) if res[i] == 1] 
    M = len(Bs)

    print(M)
    print(" ".join(map(str, Bs)))
else:
    print("-1")

Submission status: Wrong Answer

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

ok = True
res = [0] * N
for i in range(N-1):
    j = N - i
    m = int(N / j)
    s = sum([res[j*k-1] for k in range(2, m+1)])
    if As[j-1] - s > 1:
        ok = False
        break
    res[j-1] = As[j-1] - s

s = sum(res)
if ok:
    Bs = [i+1 for i in range(len(res)) if res[i] == 1] 
    M = len(Bs)

    print(M)
    print(" ".join(map(str, Bs)))
else:
    print("-1")

Submission status: Wrong Answer

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

ok = True
res = [0] * N
for i in range(N):
    j = N - i - 1
    m = int(N / (j+1))
    s = sum([res[k] for k in range(1, m)])
    if As[j] - s > 1:
        ok = False
        break
    res[j] = As[j] - s

if ok:
    Bs = [i+1 for i in range(len(res)) if res[i] == 1] 
    M = len(Bs)

    print(M)
    print(" ".join(map(str, Bs)))
else:
    print("-1")

Submission status: Wrong Answer

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

ans = [0 for i in range(N)]

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

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

print(len(anslist))
print(*anslist)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

print(len(ans)-1)
print(*ans)

Submission status: Wrong Answer

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

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

for i in reversed(range(1, N+1)):
    tmp = 0
    for j in reversed(range(i, N+1)):
        if j == i:
            if tmp % 2 == 0:
                ans[j-1] = 1
            else:
                ans[j-1] = 0
        elif j % i == 0:
            tmp += ans[j-1]

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

Submission status: Wrong Answer

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

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

for i in reversed(range(1, N+1)):
    tmp = 0
    for j in reversed(range(i, N+1)):
        if j == i:
            if tmp % 2 == 0:
                ans[j-1] = 1
            else:
                ans[j-1] = 0
        elif j % i == 0:
            tmp += ans[j-1]

print(len(ans))
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
amari= list(map(int, input().split()))
result=np.array([])

for i in range(N//2+1,N+1):
    if amari[i-1]==1:
        result = np.append(result,i)
for j in list(reversed(range(1,N//2+1))):
    if amari[j-1]==1:
        if len(result[result%j==0])%2==0:
            result=np.append(result,j)
    if amari[j-1]==0:
        if len(result[result%j==0])%2==1:
            result=np.append(result,j)
            
results = result.tolist()
print(len(results))            
print(*np.sort(results))

Submission status: Wrong Answer

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

ans = [1 for i in range(n+1)]; ans[0] = 0
for i in range(n,0,-1):
    s = 0
    for j in range(i*2,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 0

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

Submission status: Wrong Answer

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

ans = [1 for i in range(n+1)]
for i in range(n,0,-1):
    s = 0
    for j in range(i*2,n+1,i): s += ans[j]
    if (s - a[i-1])%2 == 0: pass
    else: ans[i] = 0

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

Submission status: Wrong Answer

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

ans = [0] * n

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

    return divisors

for i in reversed(range(n)):
    if li[i] == 1:
        ans[i] = 1
        for j in make_divisors(i):
            li[j] = (li[j] + 1) % 2

print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(i+1,end = ' ')

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    b = [0] * n
    # index: 0, box num: 1
    for i in range(1, n + 1)[::-1]:
        total = 0
        for j in range(i, n, i):
            total += b[j - 1]
        if total % 2 == a[i - 1]:
            b[i - 1] = 0
        else:
            b[i - 1] = 1
    total = sum(b)
    print(total)
    if any([i for i in b if b == 1]):
        print(" ".join([str(idx + 1) for idx, v in enumerate(b) if v == 1]))


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:

n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
b_added = []
b_cnt = 0
for i in range(n,0,-1):
    mul = 1
    sum_i = 0
    while i*mul <= n:
        sum_i += a[i*mul - 1]
        mul += 1
    if a[i-1] == (sum_i%2):
        if sum_i%2 != 0:
            b_cnt += 1
            b_added.append(i)
    else:
        print(-1)
        break
else:
    print(b_cnt)
    if b_cnt != 0:
        b_added.reverse()
        print(*b_added)

Submission status: Wrong Answer

Solution code:

n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
b_added = []
b_cnt = 0
for i in range(n,0,-1):
    mul = 1
    sum_i = 0
    while i*mul <= n:
        sum_i += a[i*mul - 1]
        mul += 1
    b[i - 1] = (sum_i%2)
    if sum_i%2 != 0:
        b_cnt += 1
        b_added.append(i)

if a == b:
    print(b_cnt)
    if b_cnt != 0:
        b_added.reverse()
        print(*b_added)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:

n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
b_added = []
b_cnt = 0
for i in range(n,0,-1):
    mul = 1
    sum_i = 0
    while i*mul <= n:
        sum_i += a[i*mul - 1]
        mul += 1
    b[i - 1] = (sum_i%2)
    if sum_i%2 != 0:
        b_cnt += 1
        b_added.append(i)

if a == b:
    print(b_cnt)
    if b_cnt != 0:
        #b_added.reverse()
        print(*b_added)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:

n = int(input())
a = [int(i) for i in input().split()]
b = []
b_added = []
b_cnt = 0
for i in range(1,n+1):
    mul = 1
    sum_i = 0
    while i*mul <= n:
        sum_i += a[i*mul - 1]
        mul += 1
    b.append(sum_i%2)
    if sum_i%2 != 0:
        b_cnt += 1
        b_added.append(sum_i%2)

if a == b:
    print(b_cnt)
    if b_cnt != 0:
        print(*b_added)
else:
    print(-1)

Submission status: Wrong Answer

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

for i in reversed(range(1,N+1)):
    count = 0
    total = 0
    # 倍数
    for j in range(i, N+1, i):
        count += 1
        total += ans[j-1]
        print(total)
    # 倍数が一つのとき
    if count == 1:
        if nums[i-1] == 0:
            ans[i-1] = 0
        else:
            ans[i-1] = 1
    # 倍数が複数ある
    else:
        # 指定が偶数
        if nums[i-1] == 0:
            if total % 2 != 0:
                ans[i-1] = 1
        else:
            if total % 2 == 0:
                ans[i-1] = 1


# 出力フォーマット処理
result = [i+1 for i in range(len(ans)) if ans[i] == 1]
result = [str(i) for i in result]
print(len(result))
print(" ".join(result))

Submission status: Wrong Answer

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



for i in reversed(range(1,N+1)):
    count = 0
    total = 0
    # 倍数
    for j in range(1, N+1, i):
        count += 1
        total += ans[j-1]
    # 倍数が一つのとき
    if count == 1:
        if nums[i-1] == 0:
            ans[i-1] = 0
        else:
            ans[i-1] = 1
    # 倍数が複数ある
    else:
        # 指定が偶数
        if nums[i-1] == 0:
            if total % 2 != 0:
                ans[i-1] = 1
        else:
            if total % 2 == 0:
                ans[i-1] = 1





# 出力フォーマット処理
result = [i+1 for i in range(len(ans)) if ans[i] == 1]
result = [str(i) for i in result]
print(len(result))
print(" ".join(result))

Submission status: Wrong Answer

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

for i in reversed(range(1,N+1)):
    count = 0
    total = 0
    for j in range(i,N+1):
        if j % i == 0:
            count += 1
            # 既にfixされた数を加算
            total += ans[j-1]

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0]+[int(x) for x in input().split()]
res = [0]*(N+1)
sum_res = 0
for i in range(N):
    # 今見てるところ
    k = N-i
    tmp = 0
    for j in range(k,N+1,k):
       	tmp += res[j]
    res[k] = A[k] - tmp%2
    sum_res += res[k]
 
print(sum_res)
print(' '.join([str(i) for i,x in enumerate(res) if x==1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0]+[int(x) for x in input().split()]
res = [0]*(N+1)
sum_res = 0
for i in range(N):
    # 今見てるところ
    k = N-i
    tmp = 0
    for j in range(k,N,k):
       	tmp += res[j]
    res[k] = A[k] - tmp%2
    sum_res += res[k]
 
print(sum_res)
print(' '.join([str(i) for i,x in enumerate(res) if x==1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0]+[int(x) for x in input().split()]
res = [0]*(N+1)
sum_res = 0
for i in range(N):
    # 今見てるところ
    k = N-i
    tmp = 0
    for j in range(k,N,k):
       	tmp += res[j]
    res[k] = A[k] - tmp%2
    sum_res += res[k]

print(res)
print(' '.join([str(i) for i,x in enumerate(res) if x==1]))

Submission status: Wrong Answer

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

dp = [0]*N

for i in range(N):
    number = N-i
    if a[number-1] == 1:
        if N // number == 1:
            dp[number-1] = 1
        else:
            ans = 0
            for j in range(2, (N // number)+1):
                ans += dp[j*number-1]
                ans %= 2
            if ans == 1:
                pass
            else:
                dp[number-1] = 1
    else:
        if N // number == 1:
            dp[number-1] = 0
        else:
            ans = 0
            for j in range(2, (N // number)+1):
                ans += dp[j*number-1]
                ans %= 2
            if ans == 1:
                print(-1)
                exit()
            else:
                dp[number-1] = 0

print(dp.count(1))
for (i, j) in enumerate(dp):
    if j == 1:
        print(i+1, end="")

Submission status: Wrong Answer

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

ans = [-1]
ans.extend([0 for i in range(N)])

for i in reversed(range(1, N+1)):
    tmp = 0
    for j in reversed(range(i,N+1)):
        if j == i:
            if tmp % 2 == 0:
                ans[j] = 1
            else:
                ans[j] = 0
        if j % i == 0:
            tmp += ans[j]

print(len(ans)-1)
print(ans[1:])

Submission status: Wrong Answer

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

ans = []
for i in range(n):
    ans.append(0)

for i in range(n-1, -1, -1):
    ans[i] = sum(a[i::i+1]) % 2

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

Submission status: Wrong Answer

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

ans = []
for i in range(n):
    ans.append(0)

for i in range(n-1, -1, -1):
    ans[i] = sum(a[i::i+1]) % 2

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

Submission status: Wrong Answer

Solution code:
n=int(input())
balls=list(map(int,input().split()))
ans=[0]*n;m=0;al=[]
for i in range(n)[::-1]:
  d=i+1
  c=n//d
  mal=2
  check=0
  while d*mal<=n:
    check+=ans[d*mal-1]
    mal+=1
  if check!=balls[i]:
    ans[i]=1
    al.append(str(d))
    m+=1
print(m)
print(" ".join(al))

Submission status: Wrong Answer

Solution code:
n=int(input())
balls=list(map(int,input().split()))
ans=[0]*n;m=0;al=[]
for i in range(n)[::-1]:
  d=i+1
  c=n//d
  check=0
  while d*(c+1)<=n:
    check+=ans[d*(c+1)-1]
    c+=1
    check%=2
  if check!=balls[i]:
    ans[i]=1
    al.append(str(d))
    m+=1
print(m)
print(" ".join(al))

Submission status: Wrong Answer

Solution code:
n=int(input())
balls=list(map(int,input().split()))
ans=[0]*n;m=0;al=[]
for i in range(n)[::-1]:
  d=i+1
  c=n//d
  check=0
  while d*(c+1)<=n:
    check+=ans[d*(c+1)-1]
    c+=1
  if check!=balls[i]:
    ans[i]=1
    al.append(str(d))
    m+=1
print(m)
print(" ".join(al))

Submission status: Wrong Answer

Solution code:
n = int(input())
t = list(map(int, input().split()))
for i in range(n):
    t[i] = t[i] % 2
result = [i+1 for i, x in enumerate(t) if x == 1]

if len(result) == 0:
    print(0)
else:
    print(len(result))
    print(" ".join(list(map(str, result))))

Submission status: Wrong Answer

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


def check_condition(balls):
    total_num_ball = [0] * n
    for i in range(1, n+1):
        for k in range(i, n+1, i):
            total_num_ball[i-1] += balls[k-1]

    return all([
        b % 2 == a 
        for a, b in zip(a_list, total_num_ball)
    ])


from itertools import product

flag = True
for k in product([0, 1], repeat=n):
    if check_condition(k):
        flag = False
        if sum(k) == 0:
            print(0)
            print()
        else:
            print(sum(k))
            print(*k)
        break

if flag:
    print(-1)

Submission status: Wrong Answer

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


def check_condition(balls):
    total_num_ball = [0] * n
    for i in range(1, n+1):
        for k in range(i, n+1, i):
            total_num_ball[i-1] += balls[k-1]

    return all([
        b % 2 == a 
        for a, b in zip(a_list, total_num_ball)
    ])


from itertools import product

flag = True
for k in product([0, 1], repeat=n):
    if check_condition(k):
        flag = False
        if sum(k) == 0:
            print(0)
        else:
            print(sum(k))
            print(*k)
        break

if flag:
    print(-1)

Submission status: Wrong Answer

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


def check_condition(balls):
    total_num_ball = [0] * n
    for i in range(1, n+1):
        for k in range(i, n+1, i):
            total_num_ball[i-1] += balls[k-1]

    return all([
        b % 2 == a 
        for a, b in zip(a_list, total_num_ball)
    ])


from itertools import product

flag = False
for k in product([0, 1], repeat=n):
    if check_condition(k):
        flag = True
        if sum(k) == 0:
            print(0)
        else:
            print(sum(k))
            print(*k)
        break

if flag:
    print(-1)

Submission status: Wrong Answer

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


def check_condition(balls):
    total_num_ball = [0] * n
    for i in range(1, n+1):
        for k in range(i, n+1, i):
            total_num_ball[i-1] += balls[k-1]

    return all([
        b % 2 == a 
        for a, b in zip(a_list, total_num_ball)
    ])


from itertools import product

for k in product([0, 1], repeat=n):
    if check_condition(k):
        if sum(k) == 0:
            print(0)
        else:
            print(sum(k))
            print(*k)
        break

Submission status: Wrong Answer

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


def check_condition(balls):
    total_num_ball = [0] * n
    for i in range(1, n+1):
        for k in range(i, n+1, i):
            total_num_ball[i-1] += balls[k-1]

    return all([
        b % 2 == a 
        for a, b in zip(a_list, total_num_ball)
    ])


from itertools import product

for k in product([0, 1], repeat=n):
    if check_condition(k):
        if sum(k) == 0:
            print(0)
        else:
            print(sum(k))
            print(*k)

Submission status: Wrong Answer

Solution code:
import sys

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

sys.setrecursionlimit(1 + 2 * 10 ** 5)

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) % 2 != A[i]:
            return False
    return True

def dfs(s=[]):
    if check(s):
        if len(s) == N:
            return s
        return dfs(s + [0])
    else:
        if len(s) == N:
            return None
        return dfs(s + [1])

if sum(A) == 0:
    print(0)
else:
    ret = dfs()
    if ret is None:
        print(-1)
    else:
        ans = []
        for i in range(len(ret)):
            if ret[i] == 1:
                ans.append(i+1)
        print(len(ans))
        if len(ans) > 0:
            print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

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

sys.setrecursionlimit(1 + 2 * 10 ** 5)

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) % 2 != A[i]:
            return False
    return True

def dfs(s=[]):
    if not check(s):
        return None
    if len(s) == N:
        return s

    ret0 = dfs(s + [0])
    if ret0 is not None:
        return ret0

    ret1 = dfs(s + [1])
    if ret1 is not None:
        return ret1
    return None


if sum(A) == 0:
    print(0)
else:
    ret = dfs()
    if ret is None:
        print(-1)
    else:
        ans = []
        for i in range(len(ret)):
            if ret[i] == 1:
                ans.append(i+1)
        print(len(ans))
        if len(ans) > 0:
            print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

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


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

Submission status: Wrong Answer

Solution code:
import sys

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

sys.setrecursionlimit(1 + 2 * 10 ** 5)

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) % 2 != A[i]:
            return False
    return True

def dfs(s=[]):
    if not check(s):
        return None
    if len(s) == N:
        return s

    ret0 = dfs(s + [0])
    if ret0 is not None:
        return ret0

    ret1 = dfs(s + [1])
    if ret1 is not None:
        return ret1
    return None


if sum(A) == 0:
    print(0)
if A[0] == 1 and sum(A[1:]) == 0:
    print(1)
    print(1)
else:
    ret = dfs()
    if ret is None:
        print(-1)
    else:
        ans = []
        for i in range(len(ret)):
            if ret[i] == 1:
                ans.append(i+1)
        print(len(ans))
        if len(ans):
            print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

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

sys.setrecursionlimit(1 + 2 * 10 ** 5)

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) % 2 != A[i]:
            return False
    return True

def dfs(s=[]):
    if not check(s):
        return None
    if len(s) == N:
        return s

    ret0 = dfs(s + [0])
    if ret0 is not None:
        return ret0

    ret1 = dfs(s + [1])
    if ret1 is not None:
        return ret1
    return None


if sum(A) == 0:
    print(0)
elif sum(A) == N:
    print(-1)
else:
    ret = dfs()
    if ret is None:
        print(-1)
    else:
        ans = []
        for i in range(len(ret)):
            if ret[i] == 1:
                ans.append(i+1)
        print(len(ans))
        if len(ans):
            print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

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

sys.setrecursionlimit(1 + 2 * 10 ** 5)

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) % 2 != A[i]:
            return False
    return True

def dfs(s=[]):
    if sum(A) == 0:
        return []
    if not check(s):
        return None
    if len(s) == N:
        return s

    ret0 = dfs(s + [0])
    if ret0 is not None:
        return ret0

    ret1 = dfs(s + [1])
    if ret1 is not None:
        return ret1
    return None

ret = dfs()

if ret is None:
    print(-1)
else:
    ans = []
    for i in range(len(ret)):
        if ret[i] == 1:
            ans.append(i+1)
    print(len(ans))
    if len(ans):
        print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

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

sys.setrecursionlimit(1 + 2 * 10 ** 5)

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) % 2 != A[i]:
            return False
    return True

def dfs(s=[]):
    if not check(s):
        return None
    if len(s) == N:
        return s

    ret0 = dfs(s + [0])
    if ret0 is not None:
        return ret0

    ret1 = dfs(s + [1])
    if ret1 is not None:
        return ret1
    return None

ret = dfs()

if ret is None:
    print(-1)
else:
    ans = []
    for i in range(len(ret)):
        if ret[i] == 1:
            ans.append(i+1)
    print(len(ans))
    if len(ans):
        print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2 * 10 ** 5)

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

def check(s):
    for i in range(len(s)):
        if sum(s[i::i+1]) % 2 != A[i]:
            return False
    return True

def dfs(s):
    if not check(s):
        return None
    if len(s) == N:
        return s

    ret0 = dfs(s + [0])
    if ret0 is not None:
        return ret0

    ret1 = dfs(s + [1])
    if ret1 is not None:
        return ret1
    return None

ret = dfs([])

if ret is None:
    print(-1)
else:
    c = 0
    ans = []
    for i in range(len(ret)):
        if ret[i] == 1:
            ans.append(i+1)
    print(len(ans))
    print(*ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

B = [0] * N

for n in range(N):
    idx = N - n

    a = A[idx - 1]

    q = N // idx

    target = [idx * i - 1 for i in range(2, q + 1)]
    r = sum(A[target]) % 2

    if a == 0:
        if r == 1:
            B[idx - 1] = 1
        else:
            B[idx - 1] = 0
    else:
        if r == 1:
            B[idx - 1] = 0
        else:
            B[idx - 1] = 1

g = sum(B)
print(g)

if g != 0:
    print(*list(np.where(np.array(B) == 1)[0] + 1))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
box=[0]*n
for i in range(n-1,-1,-1):
    if n//(i+1)<=1 and A[i]==1:
        box[i]=1
    elif n//(i+1)<=1 and A[i]==0:
        pass
    elif n//(i+1)>1:
        if A[i]==sum(box[2*(i+1)-1::(i+1)])%2:
            pass
        elif A[i]!=sum(box[2*(i+1)-1::(i+1)])%2:
            box[i]=1
ans=""
cnt=0
for i in range(n):
    if box[i]==1:
        ans+=str(A[i])+" "
        cnt+=1
if cnt==sum(box):
    print(sum(box))
    print(ans)
else:print("-1")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
box=[0]*n
for i in range(n-1,-1,-1):
    if n//(i+1)<=1 and A[i]==1:
        box[i]=1
    elif n//(i+1)<=1 and A[i]==0:
        pass
    elif n//(i+1)>1:
        if A[i]==sum(box[2*(i+1)-1::(i+1)])%2:
            pass
        elif A[i]!=sum(box[2*(i+1)-1::(i+1)])%2:
            box[i]=1
ans=""
for i in range(n):
    if box[i]==1:
        ans+=str(A[i])+" "
if sum(box)%2==A[0]:
    print(sum(box))
    print(ans)
else: print("-1")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
box=[0]*n
for i in range(n-1,-1,-1):
    if n//(i+1)<=1 and A[i]==1:
        box[i]=1
    elif n//(i+1)<=1 and A[i]==0:
        pass
    elif n//(i+1)>1:
        if A[i]==sum(box[2*(i+1)-1::(i+1)])%2:
            pass
        elif A[i]!=sum(box[2*(i+1)-1::(i+1)])%2:
            box[i]=1
ans=""
for i in range(n):
    if box[i]==1:
        ans+=str(A[i])+" "
if sum(box)%2==A[i]:
    print(sum(box))
    print(ans)
else: print("-1")

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
box=[0]*n
for i in range(n-1,-1,-1):
    if n//(i+1)<=1 and A[i]==1:
        box[i]=1
    elif n//(i+1)<=1 and A[i]==0:
        pass
    elif n//(i+1)>1:
        if A[i]==sum(box[2*(i+1)-1::(i+1)])%2:
            pass
        elif A[i]!=sum(box[2*(i+1)-1::(i+1)])%2:
            box[i]=1
print(sum(box))
ans=""
for i in range(n):
    if box[i]==1:
        ans+=str(A[i])+" "
if sum(box)!=0:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
inf = input().split()
A = {i+1:int(inf[i]) for i in range(N)}
ans = [0 for i in range(N+1)]
keys = list(A.keys())
keys.sort(reverse=True)
for k in keys[::-1]:
  count = 0
  for j in range(2*k, N, k)[::-1]:
    count += ans[j]
  ans[k] = (A[k]-(count%2))%2
value = sum(ans)
print(value)
if value>0:
  tag = []
  for i in range(N+1):
    if ans[i]:
      tag += [str(i)]
  print(' '.join(tag))

Submission status: Wrong Answer

Solution code:
N = int(input())
inf = input().split()
if inf[0]==1:
  print(-1)
else:
  A = {i+1:int(inf[i]) for i in range(N)}
  ans = [0 for i in range(N+1)]
  keys = list(A.keys())
  keys.sort(reverse=True)
  for k in keys[::-1]:
    count = 0
    for j in range(2*k, N, k)[::-1]:
      count += ans[j]
    ans[k] = (A[k]-(count%2))%2
  value = sum(ans)
  print(value)
  tag = []
  for i in range(N+1):
    if ans[i]:
      tag += [str(i)]
  print(' '.join(tag))

Submission status: Wrong Answer

Solution code:
N = int(input())
inf = input().split()
A = {i+1:int(inf[i]) for i in range(N)}
ans = [0 for i in range(N+1)]
keys = list(A.keys())
keys.sort(reverse=True)
for k in keys[::-1]:
  count = 0
  for j in range(2*k, N, k)[::-1]:
    count += ans[j]
  ans[k] = (A[k]-(count%2))%2
value = sum(ans)
print(value)
tag = []
for i in range(N+1):
  if ans[i]:
    tag += [str(i)]
print(' '.join(tag))