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:
#!/usr/bin/env python3
import sys

MOD = 2  # type: int


def solve(N: int, a: "List[int]"):
    tf = [0] * N
    # # 前処理
    # for i in range(1,N+1):
    #     if(a[i-1] == 0):
    #         for j in range(i,N+1,i):
    #             tf[j-1] = -1

    # # a[i]を配布していく。配布しきれなかったら-1
    # for i in range(N):
    #     if(a[i] != 0 and tf[i] != -1):
    #         idx = i
    #         while(idx < N or a[i] > 0):
    m = 0
    x = []
    for i in range(N-1, -1, -1):
        if(tf[i]%2 != a[i]):
            m += 1
            x.append(i+1)
            tf[i] = (tf[i]+1)%2
        
    print(m)
    if(x):
        print(' '.join(map(str, x)))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans_list = [0 for _ in range(n)]

for i in range(n-1, -1, -1):
    prev = 0
    for j in range(2, n+1):
        if i * j >= n: break
        prev += ans_list[i*j]
    if prev % 2 != a[i]:
        ans_list[i] = 1

print(sum(ans_list))
if sum(ans_list) != 0:
    print(' '.join([str(i+1) for i, x in enumerate(ans_list) if x == 1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans_list = [0 for _ in range(n)]

for i in range(n-1, -1, -1):
    prev = 0
    for j in range(2, n+1):
        if i * j >= n: break
        prev += ans_list[i*j]
    if prev % 2 != a[i]:
        ans_list[i] = 1

print(sum(ans_list))
if sum(ans_list) != 0:
    print(''.join([str(i+1) for i, x in enumerate(ans_list) if x == 1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans_list = [0 for _ in range(n)]

for i in range(n-1, -1, -1):
    prev = 0
    for j in range(1, n+1):
        if i * j >= n: break
        prev += ans_list[i*j]
    if prev % 2 != a[i]:
        ans_list[i] = 1

print(sum(ans_list))
if sum(ans_list) != 0:
    print(''.join([str(i+1) for i, x in enumerate(ans_list) if x == 1]))

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
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 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)

    # divisors.sort()
    return divisors

n = INT()
A = LIST()
ans = [0]*n
for i in range(n-1,-1,-1):
    if A[i] == 1:
        ans[i] = 1
    divisor = make_divisors(i+1)
    for j in divisor:
        A[j-1] = (A[j-1] + 1)%2

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
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()))

n = INT()
A = LIST()
ans = [0]*n
for i in range(n-1,-1,-1):
    res = 0
    j = 0
    while (j+1) *(i+1) <= n:
        res += ans[(j+1)*(i+1)-1]
        j += 1
    if res%2 != A[i]:
        ans[i] = 1
print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(i+1, end = '')

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
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()))

n = INT()
A = LIST()
ans = [0]*n
for i in range(n-1,-1,-1):
    res = 0
    j = 0
    while (j+1) *(i+1) <= n:
        res += ans[(j+1)*(i+1)-1]
        j += 1
    if res%2 != A[i]:
        ans[i] = 1
print(ans.count(1))
for i in range(n):
    print(str(ans[i]) + ' ', end = '')

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
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 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)

    # divisors.sort()
    return divisors

n = INT()
A = LIST()
ans = [0]*n
for i in range(n-1,-1,-1):
    if A[i] == 1:
        ans[i] = 1
    divisor = make_divisors(i+1)
    for j in divisor:
        A[j-1] = (A[j-1] + 1)%2

print(ans.count(1))
print(ans)

Submission status: Wrong Answer

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

for _i in range(N):
    i = N-_i
    cur = i * 2
    sum_b = 0
    print('i', i)

    if i == 0:
        break

    while cur <= N:
        # print(i-1, cur)
        sum_b += B[cur-1]
        cur += i

    b = (sum_b + A[i-1]) % 2

    # print(i, b)
    if b == 1:
        B[i-1] = b
        bc += 1

# print(B)
print(bc)
if bc > 0:
    print(' '.join([str(i+1) for i in range(N) if B[i] > 0]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
dp = [0] * N
bc = 0
dp[N-1] = A[N-1]

for _i in range(1, N):
    i = N-1-_i
    cur = i
    sum_b = 0

    while cur > N-1:
        sum_b += B[cur]
        cur *= 2

    b = (sum_b + A[i]) % 2

    # print(i, b)
    if b == 1:
        B[i] = b
        bc += 1

# print(B)
print(bc)
if bc > 0:
    print(' '.join([str(i+1) for i in range(N) if B[i] > 0]))

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ball_ls = [0 for i in range(n)]
for i in range(n-1,-1,-1):
    if i == 0:
        ball_ls[i] = sum(a_ls) % 2
    else:
        ball_ls[i] = sum(a_ls[i::(i+1)]) % 2
cnt = sum(ball_ls)
ball_ls = [str(i+1) for i, ball in enumerate(ball_ls) if ball > 0]
print(cnt)
if cnt > 0:
    print(" ".join(ball_ls))

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ball_ls = [0 for i in range(n)]
for i in range(n-1,-1,-1):
    if i == 0:
        ball_ls[i] = sum(a_ls) % 2
    else:
        ball_ls[i] = sum(a_ls[1::(i+1)]) % 2
cnt = sum(ball_ls)
ball_ls = [str(i+1) for i, ball in enumerate(ball_ls) if ball > 0]
print(cnt)
if cnt > 0:
    print(" ".join(ball_ls))

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ball_ls = [0 for i in range(n)]
for i in range(n-1,-1,-1):
    if i == 0:
        ball_ls[i] = sum(a_ls)
    else:
        ball_ls[i] = sum(a_ls[1::(i+1)]) % 2
cnt = sum(ball_ls)
ball_ls = [str(i+1) for i, ball in enumerate(ball_ls) if ball > 0]
print(cnt)
if cnt > 0:
    print(" ".join(ball_ls))

Submission status: Wrong Answer

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

rs = [0] * N

for i in range(N):
    j = N - i
    rs[j - 1] = (A[j-1] + sum(rs[j - 1::j])) % 2

print(len(rs))
print(*rs)

Submission status: Wrong Answer

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

rs = []
for i in range(N):
    rs.append(sum(A[i::i+1]) % 2)

print(len(rs))
print(*rs)

Submission status: Wrong Answer

Solution code:
#134ABCD - Preparing Boxes
#部分的WA
import math
N = int(input())
a = list(map(int,input().split()))
ball = [0]*N
for i in range(N,0,-1):
    print(ball)
    stock = 0
    for j in range(i,N+1,i):
        stock += ball[j-1]
        print(stock)
    if stock %2 == 1:
        if a[i-1] ==1:
            ball[i-1] += 0
        elif a[i-1] == 0:
            ball[i-1] += 1
    elif stock %2 == 0:
        if a[i-1] ==1:
            ball[i-1] += 1
        elif a[i-1] == 0:
            ball[i-1] += 0
#print(ball)
#ans = [str(k) for k in ball]
#print(' '.join(ans))#int型ではjoinは使えない
ans1 = []
count = 0
for k in range(N):
    if ball[k] == 1:
        ans1.append(k+1)
        count += 1
ans2 = [str(l) for l in ans1]
print(count)
print(' '.join(ans2))

Submission status: Wrong Answer

Solution code:
#134ABCD - Preparing Boxes
import math
N = int(input())
a = list(map(int,input().split()))
ball = [0]*N
stock = 0
#後ろから詰める
b = math.floor(N//2)+1
#Nからb番目つまりindexでいうとN-1からb-1まで入る
for i in range(N,b-1,-1):
    if a[i-1] == 1:
        ball[i-1] += 1
        #print(ball)
    elif a[i-1] == 0:
        ball[i-1] += 0#何もしない
        #print(ball)
#b-1番目から1番目つまりindexでいうとb-2から0まで入る
for i in range(b-1,0,-1):
    for j in range(i,N+1,i):
        #print(j)
        stock += ball[j-1]
        #print(stock)
    if stock %2 == 1:
        if a[i-1] ==1:
            ball[i-1] += 0
        elif a[i-1] == 0:
            ball[i-1] += 1
    elif stock %2 == 0:
        if a[i-1] ==1:
            ball[i-1] += 1
        elif a[i-1] == 0:
            ball[i-1] += 0
#print(ball)
#ans = [str(k) for k in ball]
#print(' '.join(ans))#int型ではjoinは使えない
ans1 = []
count = 0
for k in range(N):
    if ball[k] == 1:
        ans1.append(k+1)
        count += 1
ans2 = [str(l) for l in ans1]
print(count)
print(' '.join(ans2))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
M = [0 for i in range(n)]
for i in reversed(range(1,n+1)):
    k = 0
    j = 2*i
    while j<=n:
        if M[j-1] == 1:
            k += 1
        j += i
    if (j+1)%2 == A[i-1]:
        M[i-1] = 1
B = []
for i in range(n):
    if M[i] == 1:
        B += [i+1]
print(len(B))
if len(B) > 0:
    print(*B)

Submission status: Wrong Answer

Solution code:
def solve(n, a):
    b = [-1] * n
    for i in range(n, 0, -1):
        cnt = 0
        for j in range(2*i, n+1, i):
            cnt += b[j-1]
        p = cnt % 2
        b[i-1] = p ^ a[i-1]
    print(len(b))
    print(" ".join(map(str, b)))

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

Submission status: Wrong Answer

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

a_str = ''.join(a).rstrip('0')

if len(a_str) == 1:
      print(1)
      print(1)
elif len(a_str) == 0:
      print(0)
else:
      print(-1)

Submission status: Wrong Answer

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

a_str = ''.join(a).rstrip('0')

print(a_str, len(a_str))
if len(a_str) == 1:
      print(1)
      print(1)
elif len(a_str) == 0:
      print(0)
else:
      print(-1)

Submission status: Wrong Answer

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

m=0
b=[]
print(-1)

Submission status: Wrong Answer

Solution code:
M = int(input())

for i in range(M):
    print(0,end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
b_list = [0 for _ in range(N)]
ans_list= []
ballN = 0
for i in range(N, 0, -1):
    y = 2
    x = i * y
    while x <= N:
        ballN += b_list[x-1]
        y += 1
        x = i * y
    if ballN % 2 == a_list[i - 1]:
        continue
    else:
        b_list[i-1] = 1
        ans_list.append(i)

ans = map(str, ans_list)
ans = " ".join(ans)

M = sum(b_list)
print(M)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
b_list = [0 for _ in range(N)]
ans_list= []
ballN = 0
for i in range(N, 0, -1):
    y = 2
    x = i * y
    while x < N:
        ballN += b_list[x-1]
        y += 1
        x = x * y
    if ballN % 2 == a_list[i - 1]:
        continue
    else:
        b_list[i-1] = 1
        ans_list.append(i)

ans = map(str, ans_list)
ans = " ".join(ans)

M = sum(b_list)
print(M)
print(ans)

Submission status: Wrong Answer

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

n = int(input())
a_list = [-1]
a_tmp = list(map(int, input().split()))
a_list.extend(a_tmp)

ball_list = [0]*(n+1)


for i in reversed(range(1, n+1)):
    div = n // i

    sum_ball = 0
    for j in range(1, div):
        sum_ball += ball_list[i*j]

    if a_list[i] == 1:
        if sum_ball % 2 == 0:
            ball_list[i] = 1
    else:
        if sum_ball % 2 == 1:
            ball_list[i] = 1

sb = sum(ball_list)
print(sb)
if sb != 0:
    p_a = [str(i) for i in range(1, n+1) if ball_list[i] == 1]
    print(' '.join(p_a))

Submission status: Wrong Answer

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

n = int(input())
a_list = [-1]
a_tmp = list(map(int, input().split()))
a_list.extend(a_tmp)

ball_list = [0]*(n+1)


for i in reversed(range(1, n+1)):
    div = n // i

    sum_ball = 0
    for j in range(1, div):
        sum_ball += ball_list[i*j]

    if a_list[i] == 1:
        if sum_ball % 2 == 0:
            ball_list[i] = 1
    else:
        if sum_ball % 2 == 1:
            ball_list[i] = 1

ball_list = ball_list[1:]
sb = sum(ball_list)
print(sb)
if sb != 0:
    p_a = [str(a) for a in ball_list if a == 1]
    print(' '.join(p_a))

Submission status: Wrong Answer

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

n = int(input())
a_list = [-1]
a_tmp = list(map(int, input().split()))
a_list.extend(a_tmp)

ball_list = [0]*(n+1)


for i in reversed(range(1, n+1)):
    div = n // i

    sum_ball = 0
    for j in range(1, div):
        sum_ball += ball_list[i*j]

    if a_list[i] == 1:
        if sum_ball % 2 == 0:
            ball_list[i] = 1
    else:
        if sum_ball % 2 == 1:
            ball_list[i] = 1

ball_list = ball_list[1:]
sb = sum(ball_list)
print(sb)
if sb != 0:
    [print(a) for a in ball_list if a == 1]

Submission status: Wrong Answer

Solution code:
N = int(input())

A = [0] + [int(_) for _ in input().split()]
ans = [0] * (N + 1)

for i in range(N, 1, -1):
    ans[i] = A[i]
    j = i * 2
    while j <= N:
        ans[i] += ans[j]
        j += i
    ans[i] = ans[i] % 2

spam = [i for i in range(1, N + 1) if A[i]]
print(len(spam))
if spam:
    print(*spam)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = [0] + [int(_) for _ in input().split()]
ans = [0] * (N + 1)

for i in range(N - 1, 1, -1):
    if i * 2 > N:
        ans[i] = A[i]
    elif A[i] != A[i * 2]:
        ans[i] = 1

cnt = 0
idxs = []
for i in range(1, N + 1):
    if ans[i]:
        cnt += 1
        idxs.append(i)
if cnt % 2 != A[1]:
    idxs.insert(0, 1)
print(len(idxs))
if idxs:
    print(*idxs)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = [0] + [int(_) for _ in input().split()]
ans = [0] * (N + 1)

for i in range(N - 1, 1, -1):
    if i * 2 > N:
        ans[i] = A[i]
    else:
        ans[i] = (A[i] + A[i * 2]) % 2

cnt = 0
idxs = []
for i in range(1, N + 1):
    if ans[i]:
        cnt += 1
        idxs.append(i)
if cnt % 2 != A[1]:
    idxs.insert(0, 1)
print(len(idxs))
if idxs:
    print(*idxs)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(x) for x in input().split()]
B = [0] * n

for i in reversed(range(n)):
    if i + 1 > n // 2:
        B[i] = A[i]
        # iの倍数が書かれた箱に入っているボールの個数はOK
    else:
        # iの倍数が書かれた箱に入っているボールの個数
        c = n // (i+1)
        s = 0
        for j in range(c):
            s += B[(i+1)*(j+1)-1]
        if s % 2 == A[i]:
            continue
        else:
            B[i] = 1

print(sum(B))
for i in range(len(B)):
    if B[i] == 1:
        print(i + 1, end='')
if sum(B) != 0:
    print()

Submission status: Wrong Answer

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

for i in range(n):
    if AL[i] == 1:
        print(1)
        print(i+1)
        break
    if AL[i] == 0:
        print(0)
        break
    if i == n-1:
        print(-1)

Submission status: Wrong Answer

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

for i in range(n):
        if AL[i] == 1:
            print(1)
            print(i+1)
            break
        elif AL[i] == 0:
            print(0)
            break
        else:
            print(-1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10 ** 7)

MOD = 2  # type: int


def solve(N: int, a: "List[int]"):
    m = {i: [] for i in range(N)}
    ans = [0 for x in range(N)]
    for i in range(N):
        for j in range(i, N, i + 1):
            m[j].append(i)
    for i in range(N - 1, -1, -1):
        for j in m[i]:
            ans[j] ^= a[i]
    # print(m)
    # print(ans)
    b = int(sum(ans))
    print(b)
    l = []
    if b:
        for i, x in enumerate(ans):
            if x == 1:
                l.append(i + 1)
        print(*l)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(n):
        if AL[i] == 1:
            print(1)
            print(1)
            break
        elif AL[i] == 0:
            print(0)
            break
        else:
            print(-1)

Submission status: Wrong Answer

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

for i in range(n):
        if AL[i] == 1:
            print(i+1)
            print(i+1)
            break
        elif AL[i] == 0:
            print(0)
            break
        else:
            print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
li=[0]*n
a=a[::-1]
for i in range(n):
    if a[i]!=li[i]%2:
        for j in range(n-i):
            if (n-i)%(j+1)==0:
                li[j]+=1
li2=[]
for i in range(n):
    if li[i]%2==1:
        li2+=[i+1]
print(len(li2))
print(*li2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
li=[0]*n
a=a[::-1]
for i in range(n):
    if a[i]!=li[i]%2:
        for j in range(i,n,i+1):
            li[j]+=1
li2=[]
for i in range(n):
    if li[i]%2==1:
        li2+=[n-i]
print(len(li2))
print(*li2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
li=[0]*n
a=a[::-1]
for i in range(n):
    if a[i]!=li[i]%2:
        for j in range(i,n,i+1):
            li[i]+=1
li2=[]
for i in range(n):
    if li[i]%2==1:
        li2+=[n-i]
print(len(li2))
print(*li2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[-1]+[int(x) for x in input().split()]
b=[-1]+[0]*n
for i in range(n,0,-1):
  #print(b[::i][1:],a[::i][1:])
  if sum(b[::i][1:])%2!=sum(a[::i][1:])%2:
    b[i]=int(not b[i])
    #print(b[::i][1:],a[::i][1:])
    if sum(b[::i][1:])%2!=sum(a[::i][1:])%2:
      print(-1)
      exit()

ans=[n for n,x in enumerate(b) if x==1]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[-1]+[int(x) for x in input().split()]
b=[-1]+[0]*n
for i in range(n,0,-1):
  #print(b[::i][1:],a[::i][1:])
  if sum(b[::i][1:])%2!=sum(a[::i][1:])%2:
    b[i]=int(not b[i])
    #print(b[::i][1:],a[::i][1:])
    if sum(b[::i][1:])%2!=sum(a[::i][1:])%2:
      print(-1)
      exit()

ans=[x for x in b if x==1]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[-1]+[int(x) for x in input().split()]
b=[-1]+[0]*n
for i in range(n,0,-1):
  #print(b[::i][1:],a[::i][1:])
  if sum(b[::i][1:])%2!=sum(a[::i][1:]):
    b[i]=int(not b[i])
    #print(b[::i][1:],a[::i][1:])
    if sum(b[::i][1:])%2!=sum(a[::i][1:]):
      print(-1)
      exit()

ans=[x for x in b if x==1]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
n_dict = {i:0 for i in range(1, N+1)}

for i in range(N, 0, -1):
    j = i
    a = a_list[j-1]
    temp_a = 0
    while j < N:
        temp_a += n_dict[j]
        j += i
    if temp_a % 2 == a:
        pass
    else:
        n_dict[i] = 1

ans_num = list(n_dict.values())
ans_num = ans_num.count(1)
print(ans_num)

ans_str = ""
for i in range(1, N+1):
    if n_dict[i] == 1:
        if ans_str == "":
            ans_str = str(i)
        else:
            ans_str += " "+str(i)
if ans_str == "":
    pass
else:
    print(ans_str)

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
  x=0
  for j in range(i, N+1, i):
    x+=a[i-1]
    
  if x%2!=b[i-1]:
    b[i-1]=1
    
print(sum(b))
for i in range(N):
  if b[i]==1:
    print(str(int(i+1)), end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [0] + list(map(int, input().split()))
ans = [0] * (N + 1)
an = []
for i in range(N, 0, -1):
	if sum(ans[i * 2 :: i]) != a[i]:
		ans[i] = 1
		an.append(i)
print(len(an))
Ans = [str(x) for x in an]
print(' '.join(Ans))

Submission status: Wrong Answer

Solution code:
#import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  b = [i*j for j in range(2,N//i+1)]
  for j in b:
    c +=j
  c = c%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([0]+list(map(int,input().split())))
ans = []
for i in range(N,0,-1):
  b = [i*j for j in range(2,N//i+1)]
  #print(b)
  c = sum(a[b])%2
  if c!=a[i]:
    ans.append(i)
print(len(ans))
for i in range(len(ans)):
  print(ans[i],end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([0]+list(map(int,input().split())))
ans = []
for i in range(N,0,-1):
  b = [i*j for j in range(2,N//i+1)]
  print(b)
  c = sum(a[b])%2+0
  if c!=a[i]:
    ans.append(i)
print(len(ans))
for i in range(len(ans)):
  print(ans[i],end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([0]+list(map(int,input().split())))
ans = []
for i in range(N,0,-1):
  b = [i*j for j in range(1,N//i+1)]
  #print(b)
  c = sum(a[b])%2
  if c==1 and a[i]==1:
    ans.append(i)
print(len(ans))
for i in range(len(ans)):
  print(ans[i],end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([0]+list(map(int,input().split())))
ans = []
for i in range(N,0,-1):
  b = [i*j for j in range(1,N//i+1)]
  #print(b)
  c = sum(a[b])%2
  if c==1 and a[i]==1:
    ans.append(i)
for i in range(len(ans)):
  print(ans[i],end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([0]+list(map(int,input().split())))
ans = []
for i in range(N,0,-1):
  b = [i*j for j in range(1,N//i+1)]
  print(b)
  c = sum(a[b])%2
  if c==1 and a[i]==1:
    ans.append(i)
for i in range(len(ans)):
  print(ans[i],end=" ")

Submission status: Wrong Answer

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

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

    count = 0
    ball = [0] * (N+1)

    for i in range(N, 0, -1):
        tmp = 0
        for j in range(i*2, N+1, i):
            tmp += ball[j]
        if tmp%2 != a[i-1]:
            ball[i] = 1
            count += 1
    
    print(count)
    if count > 0:
        for i in range(N):
            if ball[i] == 1:
                print(i, end=" ")
        print()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#Coding:Utf-8
N=int(input())
A=list(map(int,input().split()))
Box=[0 for i in range(N)]
BoxNum=[]

for l in reversed(range(1,N+1)):
    Incount=0
    for m in range(1,int(N/l)):
        Incount+=Box[l*m]
    if Incount%2!=A[l-1]:
        Box[l-1]+=1
        BoxNum.append(l)

print(len(BoxNum))
if len(BoxNum)!=0:
    print(" ".join(map(str,BoxNum)))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split(" ")]
b = [0 for i in range(n//2)] + a[n//2:]
for i in range(n//2-1, -1, -1):
    if sum(b[i::i+1]) != a[i]:
        b[i] = 1
te = sum(b)
if te == 0:
    print(0)
else:
    print(te)
    print(" ".join(map(str, np.where(np.array(b)==1)[0]+1)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) + sum(r[i * 2::i])) % 2
#ans = []                                                                                                            #for i, x in enumerate(r):                                                                                           #    if x:                                                                                                           #        ans.append(str(i))                                                                                          print(r.count(1))
#print(''.join(ans))                                                                                                 print(*(i for i, x in enumerate(r) if x))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) + sum(r[i * 2::i])) % 2
ans = []
for i, x in enumerate(r):
    if x:
        ans.append(str(i))
print(r.count(1))
print(''.join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) + sum(r[i * 2::i])) % 2
ans = []
for i, x in enumerate(r):
    if x:
        ans.append(i)
print(r.count(1))
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
solls = [0 for i in range(N+1)] 
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+A[j]
    if (s%2 == 0)and(A[i] == 1):
        solls[i] = 1
    if (s%2 == 1)and(A[i] == 0):
        solls[i] = 1

s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
if s!=0:
    print(*ls)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
solls = [0 for i in range(N+1)] 
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+A[j]
    if (s%2 == 0)and(A[i] == 1):
        solls[i] = 1
    if (s%2 == 1)and(A[i] == 0):
        solls[i] = 1

print(solls)
s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
if s!=0:
    print(*ls)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
solls = [0 for i in range(N+1)] 
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+A[j]
    if (s%2 == 0)and(A[i] == 1):
        solls[i] = 1
    if (s%2 == 1)and(A[i] == 0):
        solls[i] = 1

s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
print(*ls)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
solls = np.zeros(N+1)
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+A[j]
    solls[i] = (s+A[i])%2

s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
print(*ls)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
solls = np.zeros(N+1)
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]
print(A)
print(solls)

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+A[j]
    #if (s%2 == 0)and(A[i] == 1):
        #solls[i] = 1
    #if (s%2 == 1)and(A[i] == 0):
        #solls[i] = 1
    solls[i] = (s+A[i])%2

s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
print(*ls)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
solls = np.zeros(N+1)
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+A[j]
    if (s%2 == 0)and(A[i] == 1):
        solls[i] = 1
    if (s%2 == 1)and(A[i] == 0):
        solls[i] = 1

s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
print(*ls)