Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a_list = [-1] + list(map(int, input().split()))

b_list = [None] * (N + 1)
for i in range(N, 0, -1):
	b = a_list[i]
	for j in range(i * 2, N, i):
		b = b ^ b_list[j]
	b_list[i] = b

count = 0
b_list2 = []
for i in range(1, N + 1):
	if b_list[i] == 1:
		count += 1
		b_list2.append(str(i))

print(count)
print(" ".join(b_list2))

Submission status: Wrong Answer

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

b = [0] * (N + 1)
half = N // 2
b[half + 2:] = A[half + 1:]
for i in range(half, 1, -1):
    s = sum([b[j]for j in range(i * 2, N + 1, i)]) % 2
    if s != A[i]:
        b[i] = 1
s = sum(b)
if s % 2 != A[0]:
    b[1] = 1
    s += 1
print(s)
if s != 0:
    print(" ".join(map(str, b[1:])))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
m = 0
b = []
for i in range(n,0,-1):
    if n//i == 1:
        if a[i-1] == 1:
            b.insert(0, i)
            m += 1
    elif n//i >= 2:
        baisu = a[2*i-1]
        if a[i-1] == 1 and baisu == 0:
            b.insert(0, i)
            m += 1
        elif a[i-1] == 0 and baisu == 1:
            b.insert(0, i)
            m += 1


print(m)
if m == 0:
    pass
else:
    mapped_b = map(str,b)
    b_str = " ".join(mapped_b)
    print(b_str)

Submission status: Wrong Answer

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

if a[0] == 1:
    print("1\n1")

elif a[0] == 0:
    if not(1 in a):
        print("0")
    else:
        print("2\n1 1")

else:
    print("-1")

Submission status: Wrong Answer

Solution code:
N=int(input())
listA=list(map(int,input().split()))
listB=[0 for i in range(N)]
listANS=[]
for i in range(N-1,-1,-1):
  listN=listA[0:N-1:i+1]
  if len(listN)==1 and listA[i]==1:
    listB[i]=1
  elif len(listN)>1 and sum(listN)%2!=sum(listB[0:N-1:i+1])%2:
    listB[i]=1
for i in range(N):
  if listB[i]==1:
    listANS+=[i+1]
ANS=len(listANS)
print(ANS)
if ANS!=0:
  print(*listANS)

Submission status: Wrong Answer

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

for i in range(a):
  d=sum(b[i::i+1])%2
  if d==1:
    c.append(i+1)
print(len(c))
for i in range(len(c)):
  print(str(c[i]),end="")
  if i!=a-1:
    print(" ",end="")

Submission status: Wrong Answer

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

b = [0]*(N+1)
b = [0]*(N+1)
for i in range(N//2+1,N+1):
    b[i] = a[i]

for i in range(N//2,0,-1):
    if b[i*2] % 2 != a[i]:
        b[i] = 1


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

print(m)
if m > 0:
    print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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

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

for n in range(N, 0, -1):
    s = sum(B[i] for i in range(n + n, N + 1, n))
    A[n] -= s
    if not (0 <= A[n] <= 1):
        print(-1)
        exit()
    B[n] = A[n]

B = [i for i, b in enumerate(B) if b == 1]
print(len(B))
for i in B:
    print(i)

Submission status: Wrong Answer

Solution code:
import math

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

bline = line[:]
root = math.ceil(math.sqrt(n))
bline[:root] = [0]*root

for i in reversed(range(root)):
    bline[i]=(sum(bline[i::i+1])+line[i])%2

blist=[]

for i in range(len(bline)):
    if bline[i]==1:
        blist.append(i+1)

# print(line)
# print(bline)
# print(blist)

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

Submission status: Wrong Answer

Solution code:
def get_divisor(n):
    out = []
    for i in range(n-1, 0, -1):
        if i % n == 0:
            out.append(i)
    return out

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

B = [0] * n

for i in range(n, 0, -1):
    divisors = get_divisor(i)
    B[i-1] = (A[i-1] + sum(B[divisor-1] for divisor in divisors)) % 2

out = [str(i) for i in range(n) if B[i-1] == 1]

print(sum(B))
print(" ".join(out))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
m=n//2-1
for i in range(n-1,m,-1):
  b[i]=a[i]
for i in range(m,0,-1):
  x=n//i
  s=0
  for j in range(2,x+1):
    s+=b[i*j-1]
  if a[i]==0:
    b[i]=s%2
  else:
    b[i]=(s+1)%2
if a[0]==0:
  b[0]=sum(b)%2
else:
  b[0]=(sum(b)+1)%2
c=[]
for i in range(n):
  if b[i]==1:
    c.append(i+1)
print(len(c))
for i in c:
  print(i)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

B=[0]*N
kazu = 0
for i in range(N, 0, -1):
	num = N//i
	total = 0
	for n in range(1, num + 1):
		total += B[i*n - 1]
	total = total % 2
	if total != a[i - 1]:
		B[i - 1] = 1
		kazu += 1

print(kazu)
for i in range(N):
	if B[i] == 1:
		print(i + 1, end="")
print("\n")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = []
half = n//2
half_ = n-half
for i in range(half):
    if a[n-i-1] == 1:
        ans.append(n-i)
for i in range(half_):
    x = n-half_-i
    y = 0
    for j in range(n):
        if x*(j+2) <= n:
            if a[x*(j+2)-1] == 1:
                y += a[x*(j+2)-1]
        else:
            break
    ymod = y%2
    if not ymod == a[x-1]:
        ans.append(x)
s = len(ans)
print(s)
if s > 0:
    print(" ".join([str(i) for i in ans]))

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
        cnt += a[j - 1]
        j += i + 1
    if a[i] + cnt % 2 ==1:
        res_ap(i)
print(len(result))
for i in range(len(result)):
    print(result[i] + 1, end = " ")

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)
        for k in range(total):
            if k == total - 1:
                print(b[k])
            else:
                print(b[k], " ")
        exit()

print(-1)

Submission status: Wrong Answer

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

for i in range(a):
  d=sum(b[i::i+1])%2
  if d==1:
    c.append(i+1)
print(sum(c))
for i in range(len(c)):
  print(str(c[i]),end="")
  if i!=a-1:
    print(" ",end="")

Submission status: Wrong Answer

Solution code:
N,*A=list(map(int, open(0).read().split()))

ni=-1
for n in range(1, N+1):
    if A[n-1] == sum(A[n-1::n]):
        ni = n
        break

if ni == -1:
    print("-1")
    exit(0)

am=len(list(filter(lambda x: x==1, A[ni-1::ni])))
print(am)
if am > 0:
    print(" ".join(map(str, list(range(1,am+1)))))

Submission status: Wrong Answer

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

S[0] = sum(A)-A[0]
for n in range(1, N):
    i = 2
    while (n+1) * i <= N:
        S[i] += A[(n+1)*i-1]
        i += 1

M = [0 for _ in range(N)]
for i in range(N):
    if A[i] + S[i] % 2 == A[i]:
        M[i] = A[i]
    else:
        print(-1)
        exit()

print(sum(M))
for i in range(len(M)):
    kugiri = False
    if M[i] == 1:
        if kugiri:
            print(" ", end="")
        print(i+1, end="")
        kugiri = True
print()

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
  tmp = 0
  for x in range(2, N):
    j = i * x
    if j > N:
      break
    tmp += B[j - 1]

  mod = tmp % 2
  if A[i - 1] == 0:
    if mod == 0:
      pass
    else:
      B[i - 1] = 1
      M.append(str(i))
  else:
    if mod == 0:
      B[i - 1] = 1
      M.append(str(i))
    else:
      pass

print(len(M))
if len(M) > 0:
  print(' '.join(M))

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)
    print(i + 1)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ls = [0]*n
for i in range(n-1,-1,-1):
    if ((i+1)*2) - 1 >= n:
        if a[i] == 1:
            ls[i] = 1
    else:
        count = 0
        for j in range(i,n,i+1):
            count += ls[j]
        if count + 1 % 2 == a[i]:
            ls[i] = 1
check = True
for i in range(n):
    if ls[i] == 1:
        check = False
        print(i+1)
if check:print(0)

Submission status: Wrong Answer

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

for i in range(1, n+1):
    m = n // (n-i+1)
    _a = []
    _b = []
    for j in range(1,m+1):
        _a.append(a[(n-i+1)*j-1])
        _b.append((n-i+1)*j)
    if sum(_a) % 2 == a[n-i]:
        print(len(_a))
        print(' '.join(map(str, _b)))
        break
    
    if i == n:
        print('-1')

Submission status: Wrong Answer

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

ans=[0]*n

i=n-1
j=1
f=0
while i!=-1:
    while True:
        try:
            b=i+(i+1)*j
            f+=ans[b]
            j+=1
        except:
            break
    f=f%2
    if (f-s[i])==0:
        ans[i]=0
    else:
        ans[i]=1
    i-=1

print(ans.count(1))
print(" ".join(map(str,ans)))

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, end=" ")

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# N <= 2*10^5
# 1以上N以下の任意の整数iについて、iの倍数が書かれた箱に入っている
# ボールの個数の和を2で割った余りがaiである
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
a = [None] + a

box = [0 for _ in range(N)]
box = [None] + box

for i in range(N, 0, -1):
    baisu_list = [i]
    for j in range(N):
        tmp = i * j
        if tmp > N:
            break
        else:
            baisu_list.append(tmp)

    in_list = []
    not_in_list = []

    for cur in baisu_list:
        if box[cur] == 1:
            in_list.append(cur)
        else:
            not_in_list.append(cur)

    if a[i] == len(in_list)%2:
        pass
    else:
        if not_in_list:
            box[not_in_list[0]] = 1
        else:
            print(-1)
            exit()


b = [i for i in range(1, N+1) if box[i] == 1]

print(len(b))
if b:
    print(*b, sep=" ")

Submission status: Wrong Answer

Solution code:
n=input()
arr=[0]+map(int,raw_input().split())
b=[]
m=0
ans=True
for i in range(1,n+1):
    s=0
    for j in range(i,n+1,i):
        s+=arr[i]
    if s%2==arr[i]:
        if arr[i]>0:
            b.append(arr[i])
            m+=1
    if s%2!=arr[i]:
        ans=False
if ans:
    print m
    for i in b:
         print i,
else:
    print -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

print(sum(ans))
for i, a in enumerate(ans):
    if a == 1:
        print(i+1, end="")
        print(' ', end="")

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=" ")

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
    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()))[::-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
    
o=B.count(1)
print(o)
P=[[i for i, x in enumerate(B) if x ==1]]
if o!=0:
  print(*P[0])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

#A,B=map(inr,input().split())
#a=list(map(int,input().split()))
from bisect import bisect_left as bl
from bisect import bisect_right as br
from math import log

from fractions import gcd
import math
from collections import deque

import sys
input=sys.stdin.readline
#s=input()
#l=list(map(int,input().split()))
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[i for i in A]
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
for n in range(N,0,-1):
    if A[n]-B[n]==0:
        continue
    table=prime_factor(n)
    #print(table)
    l=[1]
    if n==1:
        continue
    for i,j in table.items():
        l_=[]
        for k in l:
            l_.extend([k*i**m for m in range(1,j+1)])
        l.extend(l_)
    #print(l)
    for i in l:
        if i==n:
            continue
        B[i]=1-B[i]
#print(A)
#print(B)
K=[]
for i in range(1,N+1):
    if B[i]:
        K.append(i)
if len(K):
    print(len(K))
    print(*K,sep=" ")
else:
    print(len(K))

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
  tmp = 0
  for x in range(2, N):
    j = i * x
    if j > N:
      break
    tmp += B[j - 1]

  mod = tmp % 2
  if A[i - 1] == 0:
    if mod == 0:
      pass
    else:
      B[i - 1] = 1
      M.append(str(i))
  else:
    if mod == 0:
      B[i - 1] = 1
      M.append(str(i))
    else:
      pass

print(len(M))
print(' '.join(M))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(N)]
ans = []
memo = 0
cnt = 0
for i in reversed(range(N)):
    j = 2
    while (i+1)*j <= N:
        memo += a[(i+1)*j - 1]
        j += 1
    memo = memo%2
    if memo != a[i]:
        l[i] = 1
        cnt += 1
        ans.append(str(i+1))
print(cnt)
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
N = int(input())
A = list(map(int, input().split()))
B = [-1] * N
mid = N // 2
m = 0
for i in range(N)[::-1]:
    if i >= mid:
        B[i] = A[i]
    else:
        mul_cnt = 2
        tmp = 0
        while i * mul_cnt > N:
            tmp += B[i * mul_cnt]
            mul_cnt += 1
        tmp %= 2
        B[i] = (A[i] - tmp)%2
ans_cnt = 0
ans = []
for i, b in enumerate(B):
    if b == 1:
        ans_cnt += 1
        ans.append(i+1)
print(ans_cnt)
print(' '.join(map(str, ans)))

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, n//2, -1):
  if a[i-1]:
    c[i-1] = 1
for i in range(n//2, 1, -1):
  t = i
  tt = 0
  while t<=n:
    tt += c[t-1]
    t *= 2
  if (a[i-1]==1 and tt%2==0) or (a[i-1]==0 and tt%2==1):
    c[i-1] = 1

ttt = sum(c)
if (ttt%2==0 and a[0]==1) or (ttt%2==1 and a[0]==0):
  c[0] = 1
  ttt += 1

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

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 == 0:
          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:
import sys

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

lst = [0 for _ in range(N + 1)]

ans = []
for i in reversed(range(1, N + 1)):
    if i == 1:
        lst[1] = A[i]
        if sum(lst) % 2 == A[i]:
            if A[i] == 1:
                ans.append(1)
        else:
            print(-1)
            sys.exit(0)
        break

    wa = 0
    for j in range(i*2, N+1, i):
        wa += lst[j]

    lst[i] = (wa + A[i]) % 2

    if lst[i] == 1:
        ans.append(i)

print(len(ans))
if len(ans) != 0:
    print(" ".join([str(i) for i in ans]))

Submission status: Wrong Answer

Solution code:
N,*A=list(map(int, open(0).read().split()))

ni=-1
for n in range(1, N+1):
    if A[n-1] == sum(A[n-1::n]):
        ni = n
        break

am=len(list(filter(lambda x: x==1, A[ni-1::ni])))
print(am)
if am > 0:
    print(" ".join(map(str, list(range(1,am+1)))))

Submission status: Wrong Answer

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

box = [0]*n
for i in range(2, n):
    for j in range(n//(i-1), n//i, -1):
        box[j-1] = a[j-1]
        for k in range(1, i):
            box[j-1] -= a[j*k-1]
        if box[j-1]<0:
            print(-1)
            exit()
box[0] = sum(a)
print(*box)

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
        cnt += a[j - 1]
        j += i + 1
    if a[i] + cnt % 2 ==1:
        res_ap(i)
print(len(result))
for i in range(len(result)):
    print(result[i], end = " ")

Submission status: Wrong Answer

Solution code:
n = int(input())

a = []
aa = input().split() 

for i in range(n):
    a.append(int(aa[i]))

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

memo = int(n/2)
for i in range(n-1,-1,-1):
    if i >= memo:
        ans[i] = a[i]
    else:
        memo2 = 0
        s = i+1
        t = 2
        while (s*t-1)<=(n-1):
            if a[s*t-1] == 1:
                memo2 += 1
            t += 1
        if a[i] != memo2%2:
                ans[i] = 1

v = 0
for i in range(n):
    if ans[i] == 1:
        v += 1

print(v)

for i in range(n):
    if ans[i] == 1:
        print(ans[i],end="")
        print(" ",end ="")

Submission status: Wrong Answer

Solution code:
n = int(input())
dat = list(map(int, input().split()))
res = [0] * n
#print("dat: {0}".format(dat))
for i in range(n, 0, -1):
    # i-1で参照すること
    #print(i)
    t = 0
    for j in range(0, n // i):
        #print("add:{0}".format( str( ((j+1) * i) -1 )  ))
        t += res[ ((j+1) * i) -1]

    #print("i[{0}]:  t = {1}".format(i, t))

    if t % 2 == 1:
        if dat[i-1] == 1:
            res[i-1] = 0
        else:
            res[i-1] = 1
    else:
        if dat[i-1] == 1:
            res[i-1] = 1
        else:
            res[i-1] = 0

    #print(res[i-1])
    #print("res: {0}".format(res))

c = 0
for i in range(n):
    if res[i] == 1:
        c += 1

resl = []
resc = c
for i in range(n):
    if c == 0:
        break
    if dat[i] == 1:
        c -= 1
        resl.append("1")
    else:
        resl.append("0")

print(resc)
if resc !=0:
    print(" ".join(resl))

Submission status: Wrong Answer

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

M = A[0]
chk = [0]*N

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

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:
N = int(input())
A = list(map(int, input().split()))
C = [0 for i in range(N)]

print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0] * n
ansList = []

def makeList(num):
    start = num + 1
    mul = n // start
    return [start * j - 1 for j in range(1, mul+1)]


def makeRes(indices):
    flag = 0
    for elm in indices:
        if B[elm] == 1:
            flag = (flag + 1) % 2
    return flag


for i in range(n-1, -1, -1):
    if i + 1 >  n / 2:
        if A[i] == 1:
            B[i] = 1
            ans += 1
            ansList.insert(0, i)
    else:
        indices = makeList(i)
        # print(indices)
        res = makeRes(indices)
        # print(res)
        if A[i] != res:
            B[i] = 1
            ans += 1
            ansList.insert(0, i)

print(ans)
print(*ansList)

Submission status: Wrong Answer

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

for n in range(int(N / 2), -1, -1):
    check = sum(A[i] for i in range(n, N, n+1))
    if check % 2 != A[n]:
        A[n] = 1

ans = sum(A)
print(ans)
if ans > 0:
    print(*[i+1 for i, a in enumerate(A) if a == 1], sep=" ")

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

print(sum(ans))
for i, a in enumerate(ans):
    if a == 1:
        print(a, end="")
        print(' ', end="")

Submission status: Wrong Answer

Solution code:
def incre_divisors(n, D):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            D[i-1] = 1 - D[i-1]
            if i != n // i:
                D[i-1] = 1 - D[i-1]

N = int(input())
A = list(map(int, input().split()))
B = []
D = [0 for i in range(N)]
for i in range(N):
    if A[N-i-1]:
        incre_divisors(N-i, D)
    if D[N-i-1] % 2:
        B.append(N-i)

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

Submission status: Wrong Answer

Solution code:
N=int(input())

l=list(map(int,input().split()))
l=[0]+l
ans=[]
for i in range(1,N+1):
    if l[i]==1:
        for j in range(2,10**5):
            if i*j>N:
                ans.append(i)
                break
            else:
                if l[i*j]==1:
                    print(-1)
                    exit()
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
import math

def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = 1 == int(A[i])
    return A

if __name__ == '__main__':
    N = int(input())
    a = InputToInt()

    b = []
    M = 0
    for i in range(N):
        if a[N-1-i]:
            b.append(N-i)
            M += 1
            for j in range(int(math.sqrt(N-1-i))):
                if (N-i)%(j+1) == 0:
                    a[j] = not a[j]
                    a[int((N-i)/(j+1))-1] = not a[int((N-i)/(j+1))-1]

    print(M)
    for i in b:
        print(i, end=' ')

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)
        for k in b:
            print(k, " ")
        exit()

print(-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

print(sum(ans))
for i, a in enumerate(ans):
    if a == 1:
        print(a, end="")
        print(' ')

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)
print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

n = int(input())
seq = [0]
seq.extend([int(x) for x in input().split(" ")])


def check_by_index(s, i):
    n = len(s)
    a = s[i]
    j = 1
    summation = 0
    while i * j < n:
        summation += s[i * j]
        j += 1
    residue = summation % 2
    return residue == a,


m = 0
for i in range(1, len(seq)):
    ok = check_by_index(seq, i)
    if not ok:
        print(-1)
        sys.exit(0)

m = seq.count(1)
print(m)
if m == 0:
    sys.exit(0)

indices = []
for i in range(1, len(seq)):
    if seq[i] == 1:
        indices.append(str(i))

print(" ".join(indices))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n-1,int(n/2)-1,-1):
  b[i] = a[i]
for i in range(int(n/2)-1,-1,-1):
  c = [(i+1)*x for x in range(1,int(n/(i+1))+1)]
  s = 0
  for j in c:
    s += b[j-1]
  s = s%2
  if s != a[i]:
    b[i] = 1
if sum(b) == 0:
  print(0)
else:
  for i in range(n):
    if b[i] == 1:
      print(i+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:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


N = int(input())
A = map(int, raw_input().split())
C = [0 for j in range(N)]
ANS = []

for j in range(N, 0, -1):
    m = j % 2
    am = (A[j-1] + C[j-1]) % 2
    if m != am:
        A[j-1] += 1
        ANS.append(j)
    if 0 < A[j-1]:
        div = make_divisors(j)
        for k in div:
            if k != j:
                C[k] += A[j-1]

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