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:
# -*- 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 i+1 in P:
			if A[i-1] != A[(i*2)-1]:
				ans.append(i)
		else:
			if A[i-1] != A[(i*2)-1]:
				print(-1)
				sys.exit()
		'''
		tmp = A[i-1]
		for j in range(2*i, N+1, i):
			tmp = tmp ^ A[j-1]
		if tmp == 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:
N=int(input())
A=list(map(int,input().split()))
ans=[ -1 for i in range(N) ]

p1=int(N/2)
ans=ans[0:p1]+A[p1:]

for i in range(p1):
  num=p1-i-1
  j=2
  count=0
  while(True):
    count+=ans[(num+1)*j-1]
    j+=1
    if (num+1)*j>N:break
  ans[num]=abs(count%2-A[num])
print(ans[0],end='')
for i in range(N-1):
  i=i+1
  print(' '+str(ans[i]),end='')

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

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

for k in range(N):
    i = N - 1 - k
    if i > N // 2:
        b[i] = a[i]
    else:
        count = 0
        for m in range(i, N, i + 1):
            count += b[m]
        t = count % 2
        absv = a[i] - count
        if absv == 0:
            pass
        elif absv == 1:
            b[i] = 1
        else:
            print(-1)
            sys.exit()

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

Submission status: Wrong Answer

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

def get_index(n):
    return [i for i in range(2 * n, N + 1, n)]


def f():
    F = set()
    for n in range(N, N//2, -1):
        if A[n]:
            F.add(n)

    for n in range(N//2, 1, -1):
        index = get_index(n)
        a = sum([A[i] for i in index]) % 2
        if a != A[n]:
            F.add(n)

    if len(F) % 2 != A[1]:
        F.add(1)

    return F

F = f()
print(len(F))
# if len(F) != 0:
L = list(map(str, F))
print(" ".join(L))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
A.insert(0,0)
total=sum(A)
sum=0
count=0
OK_Flag=True
OK_list=[]

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

if OK_Flag==True:
  print(count)
  if count!=0:
    print(' '.join(map(str, OK_list)))
else:
  print(-1)

Submission status: Wrong Answer

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

for i in range(N):
  b = sum(a[i::i+1])
  if b%2 == a[i] :
    for j in range(1, N//(i+1)+1):
      if a[j*(i+1)-1] == 1:
        l.append(str(j*(i+1)))
    if len(l)!= 0:
      print(len(l))
      print(' '.join(l))
    else:
      print(len(l))
    break
  else:
    count += 1
if count == N :
  print(-1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC134 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

boxnum = []
for i in range(n//2,n):
    if a[i] == 1:
        boxnum.append(i+1)
for i in range(n//2)[::-1]:
    s = 0
    k = 2
    i += 1
    if i == 1:
        if len(boxnum) == 0:
            break
        elif len(boxnum) % 2 != a[0]:
            boxnum.append(1)
            break
        else:
            break
    while i*k < n:
        if i*k in boxnum:
            s += 1
        k+=1
    if s % 2:
        boxnum.append(i+1)

m = len(boxnum)
if m == 0:
    if a[0] == 1:
        boxnum.append(1)
        m += 1
    else:
        print(m)
        quit()
if m != 0:
    boxnum.sort()
    print(m)
    for i in range(m-1):
        print(boxnum[i],end=' ')
    print(boxnum[m-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
C = [0 for i in range(N)]

for i in range(N-1, -1, -1):
    if i + 1 > N // 2:
        C[i] = A[i]
    else:
        sum_b = 0
        for k in range(1, 10**6):
            if i * k > N-1:
                break
            else:
                sum_b += C[i * k]
        if sum_b % 2 == A[i]:
            C[i] = 0
        else:
            C[i] = 1

print(sum(C))
B = []
for i in range(N):
    if C[i] == 1:
       B.append(i+1)
for i in range(len(B)):
    if i == len(B) - 1:
        print(B[i])
    else:
        print(B[i], end=" ")

Submission status: Wrong Answer

Solution code:
#

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
import math

def main():
    n = int(input())
    al = list(map(int, input().split()))

    ans = [0] * n

    half = math.ceil(n/2)-1
    for i in range(half, n):
        ans[i] = al[i]

    for i in range(half-1, -1, -1):
        num = i + 1
        val = 0
        for j in range(num * 2 - 1, n, num):
            # print(j)
            val += ans[j]

        val %= 2
        ans[i] = 0 if val == al[i] else 1

    c = ans.count(1)
    print(c)
    if c > 0:
        boxes = []
        for i in range(len(ans)):
            if ans[i] == 1:
                boxes.append(i + 1)
        print(' '.join(map(str, boxes)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if a[0] == 0:
    for i in range(round(len(a)/2),len(a)):
        if a[i] == 0:
            print(0)
            break
    print(-1)
elif a[0] == 1:
    for i in range(round(len(a)/2),len(a)):
        if a[i] == 1:
            print(0)
            break
    print(-1)

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:
            B[i]+=1
            if i != n // i:
                B[n//i]+=1

    # divisors.sort()
    #return divisors

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

B=[0]*3000000
C=[]
count=0
for i in reversed(range(N)):
    if B[i]%2!=A[i]:
        make_divisors(i+1)
        count +=1
        C.append(i+1)
print(count)
if count!=0:
    print(C[0],end="")
    for i in range(1,count):
        print(" "+str(C[i]),end="")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
ans=[0]*N
c=0
for i in range(N)[::-1]:
    I=N//(i+1)
    if I==1:
        ans[i]=a[i]
    elif I>1:
        for j in range(1,I):
            c+=ans[(j+1)*(i+1)-1]
        C=c%2
        if a[i]==1 and C==1:
            ans[i]=0
        elif a[i]==1 and C==0:
            ans[i]=1
        elif a[i]==0 and C==1:
            ans[i]=1
        elif a[i]==0 and C==0:
            ans[i]=0
print(sum(ans))
for i in range(N):
    if ans[i]==1:
        print(i+1,end=' ')

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
in_list = [int(i) for i in input().split(' ')]
out_list = []
flag = 0
for i in range(1,len(in_list)+1):
    count = 0
    div_list = in_list[i-1::i]
    count += sum(div_list)
    if count%2==in_list[i-1]:
        if count!=0:
            out_list.append(in_list[i-1])
    else :
        flag = 1
        break
if flag==1:
    print(-1)
else:
    print(len(out_list))
    map_result = map(str, out_list)
    result = ' '.join(map_result)
    print(result)

Submission status: Wrong Answer

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

box = []
odd = []
even = []
for i in range(N):
  if A[i] == 1:
    if not odd:
      box.append(1)
      odd.append(1)
    elif not even:
      box.append(1)
      even.append(1)
    else:
      box.append(2)
  else:
    box.append(0)

res = []
for i, b in enumerate(box):
  if b != 0:
    res.append(i+1)
print(len(res))
if not len(res) == 0:
  print(*res)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
total = sum(a)
if total%2 == 0 and a[0] == 1:
    print(-1)
    exit()
elif total%2 == 1 and a[0] == 0:
    print(-1)
    exit()
b = []
counter = 0
for i in range(N-1,-1,-1):
    n = i+1
    total = 0
    for j in range(n,N+1,n):
        total += a[j-1]
    if total%2 == 0 and a[i] == 0:
        pass
    elif total%2 == 1 and a[i] == 1:
        counter += 1
        b.append(n)
if counter == 0:
    print(counter)
else:
    b.sort()
    print(counter)
    print(*b, sep=" ")
    print()

Submission status: Wrong Answer

Solution code:
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

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

def main():
    N = i2n()
    A = i2nn()
    X = [0] * N
    for i in range(1, N+1):
        t = A[i-1]
        if t > 0:
            divisors = make_divisors(i)
            for d in divisors:
                X[d-1] += t
    B = []
    for i, x in enumerate(X):
        if x % 2 != 0:
            B.append(i+1)
    M = len(B)
    print(M)
    if M > 0:
        print(' '.join([str(b) for b in B]))

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = [1 for i in range(N)]

for i,a in enumerate(A):
    i = N-i-1
    if i != 0:
        partsum = 0
        if i <= N//2-1:
            for j in range(N//(i+1)):
                k = j+1
                k *= (i+1)
                partsum += ans[i]
            if partsum % 2 == 0:
                ans[i] = 0
        else:
            if A[i] == 0:
                ans[i] = 0
    else:
        if sum(ans)%2 == A[i]:
            bans = []
            for bi, b in enumerate(ans):
                if b == 1:
                    bans.append(bi+1)
            print(len(bans))
            if len(bans) != 0:
                print(*bans)
        else:
            ans[i] = 0
            bans = []
            for bi, b in enumerate(ans):
                if b == 1:
                    bans.append(bi+1)
            print(len(bans))
            if len(bans) != 0:
                print(*bans)

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):
    if sum(b[i-1::i])//2 != a[i-1]:
        b[i-1]=1

print(sum(b))
if sum(b)!=0:
    for i in range(n):
        if b[i]==1:
            print(i+1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]+[int(i) for i in input().split()]
b=[0]*(n+1)
only=int(n/2)
for i in range(only+1,n+1):
    b[i]=a[i]
for i in range(n-(only+1),0,-1):
    #print(i+1)
    sum1=0
    for j in range(i,n+1,i):
        sum1+=b[j]
    if sum1%2==a[i]:
        b[i]=0
    else:
        b[i]=1
m=b.count(1)
print(m)
for i in range(1,n+1):
    if b[i]==1:
        print(i,end=" ")

Submission status: Wrong Answer

Solution code:
#i+1の倍数の和
def sum_remainder_before_i(i, a):
    ans = 0
    j = 1
    while True:
        if (j+1)*(i+1)-1 > len(a)-1:
            return ans
        else:
            ans = ans + a[(j+1)*(i+1)-1]
            j = j + 1

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

i = N - 1
ans = [-1]*N
result = False

while True:
    sum = sum_remainder_before_i(i, ans)
    if sum % 2 == a[i]:
        ans[i] = 0
    else:
        ans[i] = 1
    if i == 0:
        break
    i = i - 1

n = 0
for i, a in enumerate(ans):
    if a == 1:
        print(i+1)
        n = n + 1

if n == 0:
    print(0)

Submission status: Wrong Answer

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

ans = []

hoge = 1
while True:
  if N <= hoge:
    break
  
  hoge = hoge * 2

for _ in range(hoge - N):
  A.append(0)

end = hoge
start = hoge // 2


while end > 1:
  for i in range(start+1, end+1):
    if i > N:
      break

    tmp = i * 2
    tmpsum = bool(A[i])
    while True:
      tmpsum = tmpsum ^ (tmp in ans)
      tmp += i

      if tmp > N:
        break


    if tmpsum:
      ans.append(i)

  end = start
  start = start // 2

tmpsum = bool(A[1])
for a in ans:
  tmpsum ^= a

if tmpsum:
  ans.append(1)

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

Submission status: Wrong Answer

Solution code:
import numpy

N = int(input())

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

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

ans = []

# print(a)

l = N//2

for i in range(l+1, N+1):
    b[i-1] = a[i-1]
    if a[i-1] == 1:
        ans.append(i)

ind = l
for _ in range(l):
    ai = a[ind - 1]
    iter = N // ind - 1
    s = 0
    for j in range(1, iter+1):
        s += a[ind + j * ind - 1]
    if (s % 2) == ai:
        b[ind - 1] = 0
    else:
        b[ind - 1] = 1
        ans.append(ind)

    if ind == 1:
        break
    else:
        ind -= 1

# print(b)
m = sum(b)
print(m)
if m != 0:
    numpy.set_printoptions(threshold=numpy.inf)
    print(numpy.array(m))

Submission status: Wrong Answer

Solution code:
import fractions
def add(n):
    return n + 1

def lcm(a):
    print(a)
    ans = a[0]
    for i in range(1, len(a)):
        ans = ans * a[i] // fractions.gcd(ans, a[i])
    return ans

if __name__ == "__main__":

    n = int(input())
    buf = input().split()
    a = [int(s) for s in buf]

    indexes = [i for i, x in enumerate(a) if x == 1]
    indexes = list(map(add, indexes))
    
    if indexes:
        num = lcm(indexes)
        if num > n:
            print("-1")
        else:
            print(num)
    else:
        print("0")

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

for i in reversed(range(N)):
    if A[i] == 1:
        put[i] = 1
        # iを素因数分解して、約数に1をxorしていく
        A[i] ^= 1
        if i != 0:
            A[0] ^= 1
        tmp = 2
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                n //= tmp
                A[tmp-1] ^= 1
            else:
                tmp += 1

ans = []
for i in range(N):
    if put[i] == 1:
        ans.append(i+1)
if len(ans) > 0:
    print(len(ans))
    print(*ans)
else:
    print(-1)

Submission status: Wrong Answer

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

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

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

s = sum(ball)
print(s)
if s != 0:
    out = str(ball.index(1) + 1)
    for i in range(int(out), N):
        if ball[i] == 1: out += ' ' + str(i+1)
    print(out)

Submission status: Wrong Answer

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

b = []
for i in range(n, 0, -1):
  f = 0
  for j in range(i, n + 1, i):
    f = f ^ a[j-1]
  if f == 1:
    b.append(i)
  else:
    a[j-1] = 0

print(len(b))
if len(b) > 0:
  print(*b)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

n=I()
a=[0]+LI()
b=[0]*(n+1)
c=[0]*(n+1)
for i in range(n,0,-1):
    if c[i]!=a[i]:
        b[i]=1 #-b[i]
        c[i]=1-c[i]
        for j in range(2,int(i**0.5+1+10**-9)):
            if i%j==0:
                c[j]=1-c[j]
                if j!=i//j: c[i//j]=1-c[i//j]
                #print('i=',i,'change',j,i//j)

s=sum(b)
if s%2!=a[1]:
    b[1]=1-b[1]
    
print(s)

ans=[]
for i in range(1,n+1):
    if b[i]==1:
        #print(i,end=' ')
        ans.append(i)
if s!=0:
    print(*ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))[::-1]
B=[0]*n
for i in range(n):
  k=n-i
  if A[i]!=(B[k-1::k].count(1))%2:
    B[k-1]=1
    
    
print(B.count(1))
P=[[i for i, x in enumerate(B) if x ==1]]
print(*P[0])

Submission status: Wrong Answer

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

if a[0] == 0:
    for i in range(round(len(a)/2),len(a)):
        if a[i] == 0:
            print("0")
            break
    print("-1")
elif a[0] == 1:
    for i in range(round(len(a)/2),len(a)):
        if a[i] == 1:
            print("0")
            break
    print("-1")

Submission status: Wrong Answer

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

for i in range(N):
    total = 0
    b = []
    for j in range(N):
        if a[j] == 1 and (j + 1) % (i + 1) == 0:
            total = total + 1
            b.append(j + 1)
    if total % 2 == a[i]:
        print(total)
        print(b)
        exit()

print(-1)

Submission status: Wrong Answer

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

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

def check(i):
    cnt = 0
    n = i
    while n <= N:
        cnt += b[n-1]
        n += i
    return cnt

for i in range(N-1,-1,-1):
    if a[i] + check(i+1) == 1:
        b[i] = 1

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

print(cnt)
L = [str(int(i)) for i in ans]
print(' '.join(L))

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
A = LI()

ans = [False]*(N+1)

for i in range(1,N+1)[::-1]:
    judge = A[i-1]
    for j in range(i, N+1, i):
        ans[i] ^= A[j-1]
    if (judge==ans[i]):
        continue
    else:
        break
else:
    M = sum(ans)
    print(M)
    for i in range(1, N+1):
        if (ans[i]):
            print(i, end=" ")
    if (M>0):
        print()
    quit()

print(-1)

Submission status: Wrong Answer

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

box = []

for i in range(N):
  if A[i] == 1:
    if i == 0:
      box.append(1)
    elif i == 1:
      box.append(1)
    else:
      box.append(2)
  else:
    box.append(0)

res = []
for i, b in enumerate(box):
  if b != 0:
    res.append(i+1)
print(len(res))
if not len(res) == 0:
  print(*res)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

N = I()
a = IL()
cnt = np.array([0]*N)

for i in range(N):
  if a[i] == 1:
    l = make_divisors(i+1)
    for j in l:
      cnt[j-1] += 1

cnt = cnt%2
M = np.count_nonzero(cnt == 1)
if M == 0:
  print(0)
else:
  print(M)
  ans = ""
  for i in range(N):
    if cnt[i] == 1:
      ans += str(i+1) + " "
  print(ans[:-1])

Submission status: Wrong Answer

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

def main():
  n = int(input())
  alist = list(map(int, input().split()))
  ans = [0 for _ in range(n+1)]
  anss = 0
  res = []
  for i in range(n, 1, -1):
    if ans[i]%2 != alist[i-1]:
      ans[i] += 1
      anss += 1
      res.append(i)
      j = 1
      while j*j <= i:
        if i % j == 1:
          ans[i] += 1
          ans[i//j] += 1
        j += 1

  if ans[1] %2 != alist[0]:
    print(anss+1)
    res.append(1)
    res.reverse()
    print(*res)
  else:
    print(anss)
    if res:
      res.reverse()
      print(*res)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

INPUT_L = [0] + A[:]
B = [0] * (N+1)

# 決まるものを入れてしまう
for i in range(N//2+1, N+1):
    B[i] = INPUT_L[i]
    
for i in range(1, N//2+1):
    #print('__', i)
    #print(B[i::i])
    sum_b = sum(B[i::i])
    if sum_b % 2 == INPUT_L[i]:
        continue
    else:
        B[i] = 1
    
ans_sum = sum(B)

if ans_sum % 2 != INPUT_L[1]:
    print(-1)
else:
    ans_list = []
    for i, b in reversed(list(enumerate(B))):
        if b != 0:
            ans_list.append(str(i))

    print(ans_sum)
    print(' '.join(ans_list))

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n = onem()

a = l()
k = 0
for i in range(n):
	if a[-(i+1)] == 1:
		k = n - i
		break

m = [0 for i in range(k+1)]
al = 0
for i in range(k,0,-1):
	co = 0
	if k // i < 2:
		m[i] = a[i-1]
		al += a[i-1]
	else:
		if i != 1:
			for j in range(1,k // i):
				co += m[i * (j+1)]
				co %= 2
			m[i] = (co ^ a[i-1])
			al += m[i]
		else:
			al %= 2
			m[1] = (al ^ a[1])

print(sum(m))
kkkk = []

for i in range(len(m)):
	if m[i] == 1:
		kkkk.append(i)
if len(kkkk) != 0:
	print(jo(kkkk))

Submission status: Wrong Answer

Solution code:
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        tmp = 1
        for e in b:
            tmp *=e
        out.append(tmp + i+1)
        a[i] = 0
        n += 1
    b.add(i+1)
print(n)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
arr=[]
c=0
for i in range(0,N):
    vec=np.zeros(N,dtype=bool)
    vec[np.arange(i,N,i+1)]=True
    if sum(A[vec])%2==A[i]:
        c+=1
        if A[i]==1:
            arr.extend([i+1])
if c==N:    
    ans=len(arr)
    print(ans)
    if ans>0:
        for i in range(ans):
            print(arr[i],end=" ")
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

N = int(input())
A = input().split(' ')

an = np.array(A, dtype=np.int64)

M = 0
b = []

for i in range(N):
   chk_num = int(N/(i+1))

   if(chk_num<2):
      continue

   M += 1
   b.append(chk_num%2)


print(M)
print(*b)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]#amari
B = [0 for _ in range(N)]
s = -1 + N//2
B[s:] = A[s:]
for i in reversed(range(s)):
  k = i+1
 # print(k)
#  print(A[i])
#  print(sum(B[i::k])%2)
  if A[i] == sum(B[i::k])%2:
    B[i] = 0
  else:
    B[i] = 1
#  print("-----")
  
print(B.count(1))
for i in range(len(B)):
  if B[i] == 1:
      print(i+1)

Submission status: Wrong Answer

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

for i, a in enumerate(A[::-1]):
    ind = N - i
    if ind > N//2:
        ans[ind-1] = a
    else:
        cnt = 0
        for j in range(2, (N // ind) + 1):
            cnt += A[j * ind - 1]
            if cnt % 2 == A[ind-1]:
                ans[ind-1] = 0
            else:
                ans[ind-1] = 1

cnt = 0
print(sum(ans))
for i, a in enumerate(ans):
    if a == 1:
        print(a)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
def cal(x):
    divisors = []
    for i in range(1, int(x**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != x // i:
                divisors.append(x//i)
    return divisors
num=[0 for _ in range(n+1)]
cnt=0
ans=[]
for k in range(n):
    if (num[n-k]+1)%2==a[-1-k]:
        ans.append(n-k)
        cnt+=1
        l=cal(n-k)
        for p in l:
            num[p]+=1
ans1=[]
for j in range(cnt):
    if j<cnt-1:
        ans1.append(str(ans[j]))
        ans1.append(" ")
    else:
        ans1.append(str(ans[j]))
print(cnt)
if len(ans1)>0:
    result=''.join(ans1)
    print(result)

Submission status: Wrong Answer

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

suma = sum(a[1:])

if a[0] == 0:
	if suma== 0:
		print(0)
	else:
		print(-1)
else:
	if suma == 1:
		i = 1
		for i in range(1, N):
			if a[i] == 1:
				break
		
		if (i-1)*2 <= N-1:
			print(-1)
		else:
			print(1)
			print(i+1)
		
	elif suma == 0:
		print(1)
		print(1)

Submission status: Wrong Answer

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

N = int(input())
a = [0]+[int(i) for i in input().split()]
ret = [0] * (N+1)

def rec(i) :
    if i == N :
        return
    rec(i+1)
    s = 0
    for j in range(i, N + 1, i) :
        s += ret[j]
    ret[i] = s^a[i]
    
rec(1)
b = []
for i in range(1, N + 1) :
    if ret[i] :
        b.append(str(i))
print(len(b))

print(' '.join(b))