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:
from sys import stdin
import heapq

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

ans = [0] * N

for i in reversed(range(N)):
    # print(i)
    # print('--')
    #print(N // (i+1))
    if N // (i+1) == 1:
        if a[i] == 0:
            ans[i] = 0
        else:
            ans[i] = 1
    else:
        if a[i] == 0:
            cnt = 0
            for j in range(N//(i+1)):
                if j == 0:
                    continue

                j = j + 1
     #           print(i)
     #           print(j)
                cnt += ans[i*j]

            if cnt % 2 == 1:
                ans[i] = 1
            else:
                ans[i] = 0

        else:
            cnt = 0
            for j in range(N//(i+1)):
                if j == 0:
                    continue

                j = j + 1
      #          print(i)
      #          print(j)
                cnt += ans[i*j]

            if cnt % 2 == 1:
                ans[i] = 0
            else:
                ans[i] = 1

M = sum(ans)
print(M)
if ans != 0:
    ans_str = [str(i) for i, x in enumerate(ans) if x == 'a']
    print(' '.join(ans_str))

Submission status: Wrong Answer

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

s = 0
M = 0

hantei = True
for i in range(1,N+1):
    for j in range(1,N//i+1):
        s = s + a[j*i]

    if s % 2 == a[i] : 
        b = []
        for j in range(1,N//i+1):
            if a[j*i] == 1: 
                M = M + 1
                b.append(j*i)
        print(M)
        for j in range(M):
            print(b[j],end=' ')
        hantei = False
        break
    s = 0
    
if hantei : print('-1')

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
a = input()
list1 = list(map(int,a.split()))
list2 = []
if not 1 in list1:
    print(0)
    sys.exit()

else:
    for i in range(N):
        if list1[i] == 1:
            print(1)
            print(i)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import heapq as hq
def main():
    n = int(input())
    a = list(map(int,input().split(' ')))
    sep = (n**0.5//1)
    ans = [0]*(n+1)
    ans_sum = 0
    for num,i in enumerate(a[::-1]):
        if n-num > sep and i:
            ans[n-num] = 1
            ans_sum += 1
        else:
            cnt = 0
            for num_2,j in enumerate(ans[min((n-num)*2,n+1):],min((n-num)*2,n+1)):
                if num_2%(n-num) == 0:
                    cnt += j
            if cnt%2 != i:
                ans[n-num] = 1
                ans_sum +=1
    print(ans_sum)
    for num,i in enumerate(ans):
        if i :
            print(num,'',end='')
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 reversed(range(1, N+1)):
    summ = 0
    #b_summ = 0
    for j in range(i, N+1, i):
        summ += a[j-1]
        #b_summ += b[j-1]
    divs = summ % 2
    b[i-1] = divs

cnt = sum(b)
print(cnt)
not_first = False
if cnt > 0:

    for j in range(N):
        if b[j] == 1:
            if not_first:
                print(" ", end="")
            print(j+1, end="")
            not_first = True
    print()

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
an = np.array(input().split(" ")).astype("int64")


if an[0] == 0:
    if n % 2 == 0:
        print("1")
        print("1")
    elif n % 2 == 1:
        print("0")
elif an[0] == 1:
    if n % 2 == 0:
        print("1")
        print("1")
    elif n % 2 == 1:
        print("0")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n = int(input())

a = [0]
for i in input().split(' '):
    a.append(int(i))

#そのままにするやつ
jissai_box = []

b = [0] * (n+1)

for i in range(n, 0, -1):
    num = i

    #該当するやつ
    gaito_num = n // i
    p = sum([b[p * i] for p in range(gaito_num)])

    if p % 2 != a[i]:
        b[i] = 1
        jissai_box.append(i)

    #print([a[p * i] for p in range(gaito_num)], p % 2, a[i], p % 2 != a[i])

#for i in range(n//2, n):
#    if i == 1:
#        b.append(i)

print(len(jissai_box))

for i in jissai_box:
    print(i, ' ', end="")
print('')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

box = [0]*N


for i in range(N//2+1, N):
    if A[i] == 1:
        box[i] = 1

def func_k(start, k):
#ｋの倍数の箱に入ってるボールの個数の偶奇を返す。startの箱にボールを入れる入れないかを決める決定的根拠になる。
    start += 1
    k += 1
    SUM = 0
    j = start + k
    while j < N:
        SUM += box[j]
        j += k

    return SUM%2
    
for i in range(N//2-1, -1, -1):
    if func_k(i,i) != A[i]:
        box[i] = 1

print(box.count(1))
for k in range(N):
    print(box[k], end=" ")

Submission status: Wrong Answer

Solution code:
from math import ceil
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
c = ceil((n+1)/2)-1
for i in range(c, n):
    if a[i] == 1:
        b[i+1] = '1'
    else:
        b[i+1] = '0'
    
for i in reversed(range(0, c)):
    d = n // (i+1)
    cn = 0
    for j in range(1, d+1, i+1):
        if b[j] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(len(b))
print(' '.join(b))

Submission status: Wrong Answer

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

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

if len(b) >= 1:
    print(len(b))
    for i in range(len(b)):
        print(str(b[i]) + " ", end="")
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def printl(a,b):
    l=[0 for i in range(b)]
    for i in a:
        l[i-1]=1
    for i in l:
        print(i,end=" ")
    print()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            if cnt!=1:
                for j in range(1,cnt):
                    arr.append(i**j)
            else:
                arr.append(i)
    arr.append(temp)
    arr.append(n)
    return arr
n=input()
n=int(n)
a=[int(i) for i in input().split()]
a2=[i for i in a]
l=[0 for i in range(n)]
ll=[]
if 1 in a:
    of=0
    for i in reversed(a):
        if i==1:
            x=factorization(n-of)
            for j in x:
                l[j-1]+=1
                a[j-1]=0
            ll.append(n-of)
        of+=1
    l=[i%2 for i in l]
    if l==a2:
        print(len(ll))
        printl(ll,n)
    else:
        print(-1)
                
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
answer = []
M=0
for i in range(n-1,-1,-1):
    if a[i] == 1:
        answer.append(1)
        M += 1
    else:
        answer.append(0)
    
print(M)
print(answer[::-1])

Submission status: Wrong Answer

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

cnt = A.count(1)
ans = ["1" for i in range(cnt)]

if len(ans) == 0:
    print(0)
else:
    print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	# = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))
	A = input().split()
	A = [int(s) for s in A]
	#P = getPrimeNumList(200000)

	ans = []
	for i,val in enumerate(A):
		if val == 0:
			ans.append(i+1)

	print(len(ans))
	if len(ans) != 0:
		ans2 = ""
		for i in reversed(ans):
			ans2 = ans2 + str(i) + " "

		print(ans2[:-1])

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

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import math
import operator
import collections

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


def xor_all(a):
    ans = 0
    for i in a:
        ans ^= i
    return ans


tmp = math.sqrt(N)
sqrt_num = 1
i = N
while tmp != 1:
    if(i > tmp):
        ans_bit = xor_all(a[:i-1:-i])
        if a[i] == ans_bit:
            ans[i] = a[i]
        else:
            print("-1")
            exit()
        i -= 1
    else:
        tmp = math.sqrt(math.floor(tmp))
        sqrt_num += 1


ans_bit = xor_all(a[:0:-1])
if a[1] == ans_bit:
    ans[1] = a[1]
else:
    print("-1")
    exit()

print(collections.Counter(ans)[1])
b = [str(i) for i, x in enumerate(ans) if x == 1]
L = ' '.join(b)
if len(b) > 0:
    print(L)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

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

b = [0] * N

num = 0

for i in range(N-1, -1, -1):
    sum = 0
    for j in range(2, N):
        if (i+1) * j < len(a):
            sum += b[(i+1)*j-1]
        else:
            break

    if sum % 2 != a[i]:
        b[i] = 1
        num += 1

print(num)

if num == 0 or num == -1:
    sys.exit(0)

flag = False

for i in range(N):
    if b[i] == 1:
        if flag == True:
            print(" ", end="")
        print(i+1, end="")
        flag = True

print("")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	# = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))
	A = input().split()
	A = [int(s) for s in A]
	#P = getPrimeNumList(200000)

	ans = []
	for i,val in enumerate(A):
		if val == 1:
			ans.append(i+1)

	print(len(ans))
	if len(ans) != 0:
		ans2 = ""
		for i in reversed(ans):
			ans2 = ans2 + str(i) + " "

		print(ans2[:-1])

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

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

result = []
res_ap = result.append

for i in range(N // 2, N)[::-1]:
    if a[i] == 1:
        res_ap(i)
for i in range(N // 2)[::-1]:
    j = 2 * (i + 1)
    while(j < N + 1):
        cnt = 0
        if (j - 1) in result:
            cnt += 1
        j += i + 1
    if a[i] + cnt % 2 == 1:
        res_ap(i)
M = len(result)
print(M)
if M != 0:
    print(result[0] + 1, end = "")
    for i in range(1, M):
        print(" " + str(result[i] + 1), end = "")

Submission status: Wrong Answer

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



dps = [0 for _ in range(N)]

ans =[]
#半分までは確定
fs = N // 2
for i in range(fs, N):
    dps[i] += A[i]
    if A[i] == 1:
        ans.append(i+1)


for i in reversed(range(fs)):
    # 考慮すべき数i*素数 < N
    if dps[2*i-1]% 2 != A[i]:
        dps[i] += 1
        ans.append(i+1)


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

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    if i+1 <= N//2:
        if a == 0:
            continue
        elif a == 1:
            chk[N-i-1] = 1
            continue
        else:
            print(-1)
            exit()
    else:
        sum_chk = sum(chk[N-i-1::N-i])
        if sum_chk == a-1:
            chk[N-i-1] = 1
            continue
        elif sum_chk == a:
            continue
        else:
            print(-1)
            exit()

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

Submission status: Wrong Answer

Solution code:
import itertools
import sys


def main():
    n = int(input())
    a = list(map(int, input().split()))
    lists = []
    for d in range(2 ** n):
        binD = bin(d)
        binD = binD[2::].zfill(n)
        lists.append([int(binD[x]) for x in range(n)])
    for i in range(2 ** n):
        test(lists[i], n, a)
    print(-1)


def test(l, n, a):
    for j in reversed(range(1, n + 1)):
        if sum(l[::j]) != a[j - 1]:
            return

    print(sum(l))
    ll = []
    for k in range(len(l)):
        if l[k] == 1:
            ll.append(k)
    if len(ll) > 0:
        print(*ll)
    sys.exit(0)


main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
box =  [0] * n
for i in reversed(range(n)):
	if a[i] == 1:
		box[i] += 1
c = box.count(1)
print(c)
if c == 0:
	exit()
def func1(lst, value):
	return [i for i, x in enumerate(lst) if x == value]
ball = func1(box,1)
print(' '.join(map(str, ball)))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]
r=list(map(int,input().split()))
for i in range(n):
  a.append(r[i])
b=[0 for i in range(n+1)]


for i in range((n//2+1),n):
  b[i]=a[i]
  
for i in range(n//2,0,-1):
  j=2
  b[i]=a[i]
  while(j*i<n):
    b[i]^=a[j*i]
    j+=1

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

print(m)
for i in range(n):
  if b[i]==1:
    print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
c = 0
d = [0] * n
ans = []
for i in range(n):
    m = n-i
    p = 1
    b = 0
    while m * p <= n:
        tmp = m * p
        if d[tmp-1] == 1:
            b += 1
        p += 1
    if b % 2 != a[m-1]:
        d[tmp-1] == 1
        ans.append(m)
        c += 1

if c%2 != a[0]:
    print('-1')
else:
    print(c)
    print(" ".join(repr(e) for e in ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in reversed(range(1, n+1)):
    if i * 2 > n:
        b[i-1] = a[i-1]
    else:
        if sum(b[i-1::i]) % 2 != a[i-1]:
            b[i-1] = a[i-1]
l = []
for i in range(n):
    if b[i] == 1:
        l.append(i+1)
print(len(l))
print(' '.join(list(map(str, l))))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = [int(i) for i in input().split()] 
B = np.zeros(N)
C = np.zeros(N)
D = []
j = 1
z = 0
for i in range(N):
  while j*(N-i) <= N:
    C[N-i-1] += A[j*(N-i)-1]
    j += 1
  B[N-i-1] = C[N-i-1] % 2
  j = 1
for i in range(N):
  if B[i] == 1:
    z += 1
    D.append(i+1)
print(z)
print(D)

Submission status: Wrong Answer

Solution code:
def inpl():
    return list(map(int, input().split()))


def func(n):
    for j in range(1, n // 2 + 1):
        if n % j == 0:
            ans[j - 1] += 1
    return


N = int(input())
A = inpl()
ans = [0 for i in range(N)]

for i in reversed(range(N)):
    ans[i] %= 2
    if ans[i] == A[i]:
        pass
    else:
        ans[i] = (ans[i] + 1) % 2

    if A[i] == 1:
        func(i + 1)

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

print(len(B))
if len(B) > 0:
    print(" ".join(map(str, B)))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
an = np.array(input().split(" ")).astype("int64")


if an[0] == 0:
    if n % 2 == 0:
        print("1")
        print("1")
    elif n % 2 == 1:
        print("0")
elif an[0] == 1:
    if n % 2 == 0:
        print("1")
        print("1")
    else:
        print("1")
        print("1")

Submission status: Wrong Answer

Solution code:
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N
half = math.ceil(N/2)
summ = 0
for i in reversed(range(N)):
    # print(i)
    if i >= half-1:
        b[i] = a[i]
    else:
        x = N//(i+1)
        for j in range(1,x):
            summ += a[(i+1)*(j+1)-1]
        judge=summ%2
        if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
            b[i] = 0
        else:
            b[i] = 1
        summ = 0
        judge =0
print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    # print(ans)
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(ans.pop())

Submission status: Wrong Answer

Solution code:
n = int(input())

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

c = [0] * n
b = []

for i in range(n-1, -1, -1):
    c[i] = a[i]
    if i ==  0:
        for j in range(1, n):
            c[i] -= c[j]
    elif n//i > 1 and n%i == 0:
        for j in range(2, n//i):
            c[i] -= c[i*j]
    elif n//i > 1:
        for j in range(2, n//i+1):
            c[i] -= c[i*j]
    c[i] = c[i] % 2
    if c[i] == 1:
        b.append(i+1)

m = len(b)

print(len(b))
print(' '.join(map(str, b)))

Submission status: Wrong Answer

Solution code:

N = int(input())
a = list(map(int, input().split() ))
b=[0] * N
for i in range(N-1,-1,-1):
    if i > (N+1)/2:
        b[i]=a[i]
    else:
        tmp_list=[s for s,ind in zip(b,range(N)) if (ind+1)%(i+1)==0]
        b[i] = abs(a[i] - sum(tmp_list)%2 )
print(sum(b))
if sum(b) > 0:
    c = [ind for s,ind in zip(b,range(N)) if s==1]
    print(" ".join(map(str,c)) )

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

box = [0]*N


for i in range(N//2+1, N):
    if A[i] == 1:
        box[i] = 1

def func_k(start, k):
#ｋの倍数の箱に入ってるボールの個数の偶奇を返す。startの箱にボールを入れる入れないかを決める決定的根拠になる。
    start += 1
    k += 1
    SUM = 0
    j = start + k
    while j < N:
        SUM += box[j]
        j += k

    return SUM%2
    
for i in range(N//2-1, -1, -1):
    print(i)
    if func_k(i,i) != A[i]:
        box[i] = 1
        
print(box)

Submission status: Wrong Answer

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

sum=0
count=0
OK_Flag=True
OK_list=[]

for i in range(1,N+1):
  sum=0
  if OK_Flag==True:  
    for j in range(i,N+1,i):    
        #print(i,A[j-1])
        sum=sum+A[j]
        #print(j,sum)
    #print(i,A[i],sum,sum%2)        
    if sum%2==1:
      count=count+1
      OK_list.append(i)
    #else:
    #  OK_Flag=False

if OK_Flag==True:
  print(count)
  if count!=0:
    for item in OK_list:
      print(item)    
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
import sys


def main():
    n = int(input())
    a = list(map(int, input().split()))
    lists = []
    for d in range(2 ** n):
        binD = bin(d)
        binD = binD[2::].zfill(n)
        lists.append([int(binD[x]) for x in range(n)])
    for i in range(2 ** n):
        test(lists[i], n, a)
    print(-1)


def test(l, n, a):
    for j in range(1, n + 1):
        if sum(l[::j]) != a[j - 1]:
            return

    print(sum(l))
    ll = []
    for k in range(len(l)):
        if l[k] == 1:
            ll.append(k)
    if len(ll) > 0:
        print(*ll)
    sys.exit(0)


main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	# = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))
	A = input().split()
	A = [int(s) for s in A]
	#P = getPrimeNumList(200000)

	ans = []
	hafe = N//2
	for i in range(N, 0, -1):
		if i > hafe:
			if A[i-1] == 1:
				ans.append(i)
			continue

		if A[i-1] == 1:
			ans.append(i)
		#if A[i-1] != A[(i*2)-1]:
			#ans.append(i)

	print(len(ans))
	if len(ans) != 0:
		ans2 = ""
		for i in reversed(ans):
			ans2 = ans2 + str(i) + " "

		print(ans2[:-1])

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

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(int)

#約数を求める
def makeDivisor(n):
    for i in range(1, int(n ** 0.5)+1):
        if n % i == 0:
            d[i] += 1
            if i != n // i:
                d[i] += 1
    return

b = [0] * N
cnt = 0
for i in range(N, 0, -1):
    if d[i] % 2 == 1 and a[i-1] == 0:
        b[i-1] = 1
        cnt += 1
        makeDivisor(i)
    elif d[i] % 2 == 0 and a[i-1] == 1:
        b[i-1] = 1
        cnt += 1
        makeDivisor(i)
    elif d[i] % 2 == 1 and a[i-1] == 1:
        print(-1)
        exit()

print(cnt)
for i in range(N):
    if b[i] == 1:
        print(i+1,end=' ')

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = list(map(int,input().split()))
b = []
'''
for i in range(N):
	for j in range(math.floor(N/(i+1))):
		print((i+1)+(i+1)*j)
	print('---')

'''
for i in range(N):
	#print(i)
	cnt = 0
	for j in range( math.floor(N/(i+1)) ):
		if a[(i+1)+(i+1)*j-1]==1:
			cnt += 1
			b.append((i+1)+(i+1)*j)
			#print(cnt)

	if cnt%2 == a[i]:
		print(cnt)
		for k in range(cnt):
			print(b[k])
		break;

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
a = input()
list1 = list(map(int,a.split()))
list2 = []
if not 1 in list1:
    print(-1)
    sys.exit()

else:
    for i in range(N):
        if list1[i] == 1:
            print(1)
            print(i)
            sys.exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
a.insert(0,0)

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

for i in reversed(range(1,int(n/2)+1)):
    c=0
    if a[i]==0:
        for j in range(2*i,n+1,i):
            if b[j]==1:
                c=c+1
        if c % 2 ==0:
            b[i]=0
        else:
            b[i]=1
    if a[i]==1:
        for j in range(2*i,n+1,i):
            if b[j]==1:
                c=c+1
        if c % 2 ==0:
            b[i]=1
        else:
            b[i]=0

if any(b)==False:
    print(0)
else:
    def func1(lst, value):
        return [i for i, x in enumerate(lst) if x == value]
    idx=func1(b,1)
    print(' '.join(map(str, idx)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
c = 0
d = [0] * n
ans = []
for i in range(n):
    m = n-i
    p = 1
    b = 0
    while m * p <= n:
        tmp = m * p
        if d[tmp-1] == 1:
            b += 1
        p += 1
    if b % 2 != a[m-1]:
        d[tmp-1] == 1
        ans.append(m)
        c += 1

if c%2 != a[0] and c > 1:
    print('-1')
else:
    print(c)
    print(" ".join(repr(e) for e in ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a2 = a.copy()
for a_num in range(1, n + 1, -1):
    count = 0
    for i in range(n // a_num):
        count += a[a_num * i]
    a2[a_num] = count % 2
print(a2.count(1))
[print(i) for i in range(1, len(a2)+1) if a2[i-1] == 1]

Submission status: Wrong Answer

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

for n in range(N):
  i = N-n
  # print(i)
  if A[i-1] == 1:
    BB = B[::i]
    B[i] = (sum(BB)+1)%2
    # print(B)
    if B[i] == 1:
      x.append(str(i))
  else:
    B[i] = 0
  
if len(x) == 0:
  print(0)
else:
  print(len(x))
  print(' '.join(x))

Submission status: Wrong Answer

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

n=int(input())
a=[int(i) for i in input().split()]
ans=[0]*n
for i in range(n-1,-1,-1):
    if a[i]==1:
        chk=0
        for j in range(2,n+1):
            if (i+1)*j<=n and a[(i+1)*j-1]:
                chk+=1
        if chk%2==0:
            ans[i]=1
cnt=ans.count(1)

if (cnt%2==0) or ans[0]:
    print(ans.count(1))
    if sum(ans):
        ans2=[]
        for i in range(n):
            if ans[i]:
                ans2.append(i+1)
        print(*ans2)
else:
    print(-1)

Submission status: Wrong Answer

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

b = [ 0 for _ in range(N)]
for i in reversed(range(1, N+1)):
    summ = 0
    b_summ = 0
    for j in range(i, N+1, i):
        summ += a[j-1]
        b_summ += b[j-1]
    divs = (summ - b_summ) % 2
    b[i-1] = divs

cnt = sum(b)
print(cnt)
not_first = False
if cnt > 0:

    for j in range(N):
        if b[j] == 1:
            if not_first:
                print(" ", end="")
            print(j+1, end="")
            not_first = True
    print()

Submission status: Wrong Answer

Solution code:
n = int(input())
figure = list(map(int, input().split()))
one = []
error = 0#０だと正常

for x in range(n):
  a = 0
  for i in range(x,n,x+1):
    if figure[i] == 1:
      a +=1
  if figure[x] != (a%2):
    error += 1
    print("-1")
    break
if error == 0:
  data = list(map(lambda x:x+1, one))
  if not data:
    print("0")
  else:
    print(*data)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, raw_input().split())
ANS = []

for j in range(N, 0, -1):
    s = 0
    for k in range(j+j, N+1, j):
        if A[k-1] == 1:
            s += 1

    am = s % 2
    if A[j-1] != am:
        A[j-1] += 1
        ANS.append(j)

print(len(ANS))
str_ANS = [str(j) for j in ANS]
print(" ".join(str_ANS))

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = list(map(int,input().split()))
ans = [0 for i in range(n)]

while n != 0:
  for i in range(int(n/2),n):#後半の処理
    if ai[i] ==1:
      ans[i] = ai[i]
      for j in range(int((i+1)/2)):#前半の処理
        if(i+1)%(j+1) ==0:
          ai[j] = 1 - ai[j]
  n = int(n/2)
if ai[0] == ans[0]:
  print(sum(ans))
  if (sum(ans) == 0):
    print(0)
    exit(0)
  else:
    for i in range(len(ans)):
      if(ans[i] == 1):
        print('{} '.format(i+1),end='')
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []
for i in range(N-1,mid-1,-1):
    k = l[i]
    MAP[i] = k
    if k==1:
        ans_l.append(str(i))
flag = False
for i in range(mid,0,-1):
    s = N // i + 1
    t = 0
    for j in range(2,s):
        t += MAP[i*j-1]
    if t%2==0:
        if l[i-1]%2==1:
            ans_l.append(str(i))
            MAP[i-1] += 1
    else:
        flag = True
    if flag:
        print('-1')
        exit()

leng = len(ans_l)
print(leng)
if leng==0:
    print(0)
else:
    print(" ".join(ans_l))

Submission status: Wrong Answer

Solution code:
from math import sqrt
n = int(input())
a = list(map(int, input().split()))

ans = {}
for i in range(1, n+1):
    xs = []
    for j in range(i-1, n, i):
        xs.append(a[j])
    ans[i] = sum(xs) % 2

print(max(ans.items(), key = lambda x:x[1])[0])
print(max(ans.values()))