Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [-1]+list(map(int,input().split()))
print(len(a))
b = [0]*(N+1)
for i in range(N,0,-1):
    su = 0
    j = 2
    while i*j <= N:
        su += a[i*j]
        j+=1
    b[i] = (a[i]+su)%2

if sum(b)>0:
    print(sum(b))
else:
    print(0)
    exit()

ans =[]
for i in range(1,N+1,1):
    if b[i]==1:
        ans.append(i)
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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

b = [0]*(N+1)
for i in range(N,0,-1):
    if i*2 > N:
        b[i]=a[i]
    else:
        su = 0
        j = 2
        while i*j <= N:
            su += a[i*j]
            j+=1
        b[i] = (a[i]-su)%2

if sum(b)>0:
    print(sum(b))
else:
    print(0)
    exit()

ans =[]
for i in range(1,N+1,1):
    if b[i]==1:
        ans.append(i)
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
 
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
 
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
 
def SI(): return input().split()
 
def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')
 
from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
 
 
def solve():
    n = II()
    A = LI()
    box = [-1] * n
    ans = deque([])
    for i in range(n, 0, -1):
        box[i-1] = A[i-1]
        j = i + i
        while j < n:
            # print(i, j, n)
            box[i] ^= box[j]
            j += i
        if box[i-1]:
            ans.appendleft(i)
 
    print(sum(box))
    if sum(box):
        printlist(ans, ' ')
 
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product


def solve():
    n = II()
    A = LI()
    box = [-1] * n
    ans = deque([])
    for i in range(n, 0, -1):
        box[i-1] = A[i-1]
        j = i + i
        while j < n:
            # print(i, j, n)
            box[i] ^= box[j]
            j += i
        if box[i-1]:
            ans.appendleft(i)

    print(sum(box))
    if sum(box):
        printlist(ans, '')

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product


def solve():
    n = II()
    A = LI()
    box = [-1] * n
    ans = deque([])
    for i in range(n-1, -1, -1):
        j = (i+1) * 2 - 1
        if j >= n:
            box[i] = A[i]
        else:
            box[i] = A[i] ^ box[j]
        if box[i]:
            ans.appendleft(i+1)
    print(sum(box))
    if sum(box):
        printlist(ans, '')

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product


def solve():
    n = II()
    A = LI()
    box = [-1] * n
    ans = deque([])
    for i in range(n-1, -1, -1):
        j = (i+1) * 2 - 1
        if j >= n:
            box[i] = A[i]
        else:
            box[i] = A[i] ^ box[j]
        if box[i]:
            ans.appendleft(i+1)
    print(sum(box))
    printlist(ans, '')

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())
    m = [0] * (n // 2 + 1)
    for i in range(n // 2, 0, -1):
        m[i - 1] = sum(a[i - 1::i]) % 2

    res = [i for i, j in enumerate(m, 1) if j]

    print(len(res))
    if len(res) != 0:
        print(' '.join(map(str, res)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())
    m = [0] * (n // 2 + 1)
    for i in range(n // 2, 0, -1):
        m[i] = sum(a[i - 1::i]) % 2

    res = [i for i, j in enumerate(m, 1) if j]

    print(len(res))
    if len(res) != 0:
        print(' '.join(map(str, res)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())
    m = [0] * (n // 2 + 1)
    for i in range(n // 2, 0, -1):
        m[i] = sum(a[i - 1::i]) % 2

    res = [i for i, j in enumerate(m) if j]

    print(len(res))
    if len(res) != 0:
        print(' '.join(map(str, res)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())
    m = [0] * (n + 1)
    res = []
    for i in range(n, 0, -1):
        x = a[i - 1] % 2
        y = m[i] % 2
        if x != y:
            res.append(i)
            c = i // 2
            j = 1
            while j < c:
                if i % j == 0:
                    m[j] += 1
                j += 1

    m = len(res)
    print(m)
    if m == 1:
        print(res[0])
    elif m > 1:
        l = ' '.join(map(str, res))
        print(l[::-1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())
    res = []
    for i in range(1, n):
        x = sum(a[i - 1::i])
        b = x % 2
        if x > 0 and b == 0:
            print(-1)
            exit()
        if a[i - 1]:
            res.append(i)

    ans = ' '.join(map(str, res))
    print(sum(a))
    if res != []:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *a = map(int, open(0).read().split())
    res = []
    for i in range(1, n):
        x = sum(a[i - 1::i])
        b = x % 2
        if x > 0 and b == 0:
            print(-1)
            exit()
        if a[i - 1]:
            res.append(i - 1)

    ans = ' '.join(map(str, res))
    print(sum(a))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input()
print(" ".join(["0"]*n))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (N + 1)
    ans = []
    for i in range(N,0,-1):
        B[i] = A[i]
        now = i * 2
        cnt = 2
        while now <= N:
            B[i] += B[now] % 2
            now = i * cnt
            cnt += 1
        
        if B[i] % 2 == 1:
            ans.append(i)

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





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    ans = []
    for i in range(N,0,-1):
        tmp = A[i]
        now = i * 2
        cnt = 2
        while now <= N:
            tmp += A[now] % 2
            now = i * cnt
            cnt += 1
        
        if tmp % 2 == 1:
            ans.append(i)

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





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[0 for _ in range(N)]
for i in range(N):
    j=N-1-i
    if sum(b[j:N:j+1])%2!=a[j]:
        b[j]=1

for k in range(N):
    if b[k]==1:
        if k<N-1:
            print(k+1,end=" ")
        else:
            print(k+1)

Submission status: Wrong Answer

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

for i in range(1,n+1)[::-1]:
    div = n // i
    sum = 0
    if div < 2:
        if a[i-1] == 1:
            ans.append(i)
            continue
    else:
        for j in range(2, div+1): 
            sum += a[i*j-1]
        if sum%2 == 1:
            if a[i-1] == 0:
                ans.append(i)
        else:
            if a[i-1] == 1:
                ans.append(i)
print(len(ans))
if len(ans) != 0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    b = [0 for i in range(n)]
    ans = []

    for i in range(n // 2, n):
        b[i] = a[i]

    for i in range(n // 2 - 1, -1, -1):
        cnt = 0
        for j in range(i * 2 + 1, n, i + 1):
            cnt ^= b[j]
        if cnt != a[i]:
            b[i] = 1
            ans.append(i + 1)

    tmp = len(ans)
    print(tmp)
    if tmp > 0:
        print(*ans, sep=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    b = [0 for i in range(n)]
    ans = []

    for i in range(n // 2, n):
        b[i] = a[i]

    for i in range(n // 2 - 1, -1, -1):
        cnt = 0
        for j in range(i + 1, n):
            cnt ^= b[j]
        if cnt != a[i]:
            b[i] = 1
            ans.append(i + 1)

    print(len(ans))
    if len(ans) > 0:
        print(*ans, sep=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

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

    for i in range(n // 2, n):
        b[i] = a[i]

    for i in range(n // 2, -1, -1):
        cnt = 0
        for j in range(i + 1, n):
            cnt ^= b[j]
        if cnt != a[i]:
            b[i] = 1

    ans = []
    for bi in b:
        if bi:
            ans.append(bi)

    print(len(ans))
    if len(ans) > 0:
        print(*ans, sep=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

m = 0
ans = [0]*N
for i in range(N, 0, -1):
    a = A[i-1]
    cnt = 0
    for k in range(i+i, N+1, i):
        cnt += A[k-1]
    if a != cnt % 2:
        ans[i-1] = 1
        m += 1

print(m)
for an in ans:
    if an > 0:
        print(an, end=' ')
print()

Submission status: Wrong Answer

Solution code:
import numpy as np 
import sys
input = sys.stdin.readline
N = int(input())
a =[0]+ list(map(int, input().split()))
a_np =np.array(a)
for i in range(N,0,-1):
    a_np[i] =np.sum(a[i::i]) %2
print(np.sum(a_np))
a_np =np.delete(a_np,0)
for i,v in enumerate(a_np):
    if v==1:
        print(i+1,end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np 
import sys
input = sys.stdin.readline
N = int(input())
a =[0]+ list(map(int, input().split()))
a_np =np.array(a)
for i in range(N,0,-1):
    a_np[i] =np.sum(a[i::i]) %2
print(np.sum(a_np))
del a[0]
for i,v in enumerate(a_np):
    if v==1:
        print(i+1,end=" ")

Submission status: Wrong Answer

Solution code:
#約数
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

# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline
N = int(input())
a =[0]+ list(map(int, input().split()))

ball ={i:0 for i in range(1,N+1)}
ball_1_list =[]
count_ball=0
for i in range(N,0,-1):
    div =make_divisors(i)
    if ball[i] %2 !=a[i]:
        ball[i] = (ball[i] +1) %2
        if ball[i] ==1:
            ball_1_list.append(i)
        for j in div:
            if ball[j] %2 !=a[j]:
                ball[j] = (ball[j] +1) %2
                if ball[i] ==1:
                    ball_1_list.append(i)

ball_1_num =len(ball_1_list)
print(ball_1_num)
if ball_1_num !=0:
    print(*ball_1_list)

Submission status: Wrong Answer

Solution code:
#約数
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

# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline
N = int(input())
a =[0]+ list(map(int, input().split()))

ball ={i:0 for i in range(1,N+1)}
ball_1_list =[]
count_ball=0
for i in range(N,0,-1):
    div =make_divisors(i)
    if ball[i] %2 !=a[i]:
        ball[i] = (ball[i] +1) %2
        if ball[i] ==1:
            ball_1_list.append(i)
        for j in div:
            if ball[j] %2 !=a[j]:
                ball[j] = (ball[j] +1) %2
                if ball[i] ==1:
                    ball_1_list.append(i)

ball_1_num =len(ball_1_list)
print(ball_1_num)
#if ball_1_num !=0:
print(*ball_1_list)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = []
count = 0
for i in range(n-1, -1, -1):
    c = sum([a[i] for j in range(i, n, i+1)])%2
    if c == 1:
        count+=1
        ans.append(i+1)
ans = ans[::-1]
print(c)
if c > 0:
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
#約数
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

# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline
N = int(input())
a =[0]+ list(map(int, input().split()))

ball_num ={i:0 for i in range(1,N+1)}
ball_1_list =[]
count_ball=0
for i in range(N,0,-1):
    div =make_divisors(i)
    if ball_num[i] %2 !=a[i]:
        ball_num[i] = (ball_num[i] +1) %2
        if ball_num[i] ==1:
            ball_1_list.append(i)
        for j in div:
            ball_num[j] = (ball_num[j] +1) %2
            if ball_num[i] ==1:
                ball_1_list.append(i)

ball_1_num =len(ball_1_list)
print(ball_1_num)
#if ball_1_num !=0:
print(*ball_1_list)

Submission status: Wrong Answer

Solution code:
#約数
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

# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline
N = int(input())
a =[0]+ list(map(int, input().split()))

ball_num ={i:0 for i in range(1,N+1)}
ball_1_list =[]
count_ball=0
for i in range(N,0,-1):
    div =make_divisors(i)
    if ball_num[i] %2 !=a[i]:
        ball_num[i] +=1
        ball_num[i] %=2
        if ball_num[i] ==1:
            ball_1_list.append(i)
        for j in div:
            ball_num[j] +=1
            ball_num[j] %=2
            if ball_num[i] ==1:
                ball_1_list.append(i)
                
ball_1_num =len(ball_1_list)
print(ball_1_num)
if ball_1_num !=0:
    print(*ball_1_list)

Submission status: Wrong Answer

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

for i in range(n):
  s[i] = sum(a[i::i+1])
  #print(a[i::i+1])

#print(s)
ans = list(map(lambda x: x%2, s))
print(sum(ans))
ans2 = ""
for i in range(n):
  if ans[i] == 1:
    ans2 = ans2 + str(i+1)
print(ans2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_ls = list(map(int, input().split()))
a_ls = [0] + a_ls
box_ls = [0] * (n+1)
root = n ** 0.5
for i in range(n,0,-1):
    if 2*i > n:
        box_ls[i] = a_ls[i]
    else:
        Sum = 0
        num = i + i
        # ここの条件式不安あり
        while num <= n:
            Sum += a_ls[num]
            num += i
        rest = Sum % 2
        if (rest == 1 and a_ls[i] == 1) or (rest == 0 and a_ls[i] == 0):
            box_ls[i] = 0
        else:
            box_ls[i] = 1
ans_ls = []
for box_name, ball_num in enumerate(box_ls[1:],1):
    if ball_num == 1:
        ans_ls.append(str(box_name))
M = len(ans_ls)
print(M)
if M > 0:
    print(' '.join(ans_ls))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_ls = list(map(int, input().split()))
a_ls = [0] + a_ls
box_ls = [0] * (n+1)
root = n ** 0.5
for i in range(n,0,-1):
    if i > root:
        box_ls[i] = a_ls[i]
    else:
        Sum = 0
        num = i + i
        # ここの条件式不安あり
        while num <= n:
            Sum += a_ls[num]
            num += i
        rest = Sum % 2
        if (rest == 1 and a_ls[i] == 1) or (rest == 0 and a_ls[i] == 0):
            box_ls[i] = 0
        else:
            box_ls[i] = 1
ans_ls = []
for box_name, ball_num in enumerate(box_ls[1:],1):
    if ball_num == 1:
        ans_ls.append(str(box_name))
M = len(ans_ls)
print(M)
if M > 0:
    print(' '.join(ans_ls))

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
N=int(input())
#N,K=map(int,input().split())
A=list(map(int,input().split()))
l=[-1]*N

for i in reversed(range(N)):
    s = 0
    if (i+1)//N>=1:
        for j in range(1,(i+1)//N):
            s+=l[i*(j+1)]
    if s%2==A[i]:
        l[i]=0
    else:
        l[i]=1
print(l.count(1))
if l.count(1) !=0:
    ll=[i for i in l if i!=0]
    print(' '.join(map(str, ll)))

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
N=int(input())
#N,K=map(int,input().split())
A=list(map(int,input().split()))
l=[-1]*N

for i in reversed(range(N)):
    s = 0
    if (i+1)//N>=1:
        for j in range(1,(i+1)//N):
            s+=l[i*(j+1)]
    if s%2==A[i]:
        l[i]=0
    else:
        l[i]=1
print(' '.join(map(str, l)))

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
N=int(input())
#N,K=map(int,input().split())
A=list(map(int,input().split()))
l=[-1]*N

for i in reversed(range(N)):
    s = 0
    if (i+1)//N>=1:
        for j in range(1,(i+1)//N):
            s+=l[i*(j+1)]
    if s%2==A[i]:
        l[i]=0
    else:
        l[i]=1
print(l)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=[0]+list(map(int,input().split()))
    ans=[0]*(N+1)
    s=[0]*(N+1)

    for i in reversed(range(1,N+1)):
        cnt=0
        for j in range(i+i,N+1,i):
            cnt^=s[j]
        if (A[i]==1 and cnt!=1) or (A[i]==0 and cnt!=0): s[i]=1
    
    print(sum(s))
    for i in s:
        if i:
            print(s.index(i))






    
resolve()

Submission status: Wrong Answer

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

ans = []

for i in range(n):
    j = n-i
    count = 0
    itr = 2
    while(1) :
        j*= itr
        if j > n :
            break
        count += ans[n-1-(j-1)]
        itr +=1
    j = n -i
    if (count%2 == a[j-1]):
        ans.append(0)
    else:
        ans.append(1)

ans.reverse()
print(sum(ans))
for i,j in enumerate(ans):
    if j == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
box = np.zeros(N+1, np.int32)
ans = []
for i in reversed(range(1, N+1)):
    # iの倍数の箱の合計
    sum_ = sum([box[i*j] for j in range(1, N//i+1)])
    if sum_ != A[i-1]:
        box[i] = 1
        ans.append(i)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n = II()
    A = LI()

    B = [-1] * n
    for i in range(n, 0, -1):
        # print(i)
        s = 0
        for j in range(i+i, n+1, i):
            # print(f' {j}')
            s ^= B[j-1]
        B[i-1] = A[i-1] ^ s
    # print(B)

    print(sum(B))
    for b in B:
        if b: print(b)



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(sum(ans))
print(*ans)

Submission status: Wrong Answer

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

def md(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
b = [0]*n
ans = []
for i in range(n-1,-1,-1):
    if (b[i]%2 != a[i]):
        c = md(i+1)
        ans.append(i+1)
        for j in c:
            b[j-1] += 1
if (b[0]>1):
    print(-1)
else:
    print(len(ans))
    print(*ans)

Submission status: Wrong Answer

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

def md(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
b = [0]*n
ans = []
for i in range(n-1,-1,-1):
    if (b[i] != a[i]):
        c = md(i+1)
        ans.append(i+1)
        for j in c:
            b[j-1] += 1
if (b[0]>1):
    print(-1)
else:
    print(len(ans))
    print(*ans)

Submission status: Wrong Answer

Solution code:
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(input())

a = list(map(int,input().split()))
b = [0]*n
for i in range(1,n+1)[::-1]:
    if(b[i-1] != a[i-1]):
        div = make_divisors(i)
        for d in div:
            b[d-1] = b[d-1]^1

l = []
for i in range(n):
    if(b[i] == 1):l.append(i+1)
print(len(l))
if(len(l) != 0):print(*l)

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
alis = li()

blis = [0]*n
for i in reversed(range(1,n+1)):
    sums = 0
    for k in range(1,n):
        if k*i > n:
            break
        sums += blis[k*i - 1]
    if (sums % 2) != alis[i-1]:
        blis[i-1] = 1

ans = 0
anl = []
for i in range(n):
    if blis[i] == 1:
        ans += 1
        anl.append(i+1)
print(ans)
if len(anl) == 0 :
    exit()
print(*anl)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=[2]+limii()
cnt=0
ans=[]
mat=[0]*(n+1)
for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=mat[j*i-1]
    
    if temp%2!=arr[i]:
        mat[i]=1

for i in range(n+1):
    if mat[i]==1:
        ans.append(i)
        cnt+=1

print(cnt)
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=[2]+limii()
cnt=0
ans=[]
mat=[0]*(n+1)
for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=mat[j*i-1]
    
    if temp%2!=arr[i]:
        mat[i]=1

for i in range(n+1):
    if mat[i]==1:
        ans.append(i)
        cnt+=1

print(cnt)
print(*list(reversed(ans)))