Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

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


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


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

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

    if len(F) % 2 != A[0]:
        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())
figure = list(map(int, input().split()))
one = []
error = 0#０だと正常

for i in range(n):
  if figure[i] == 1:
    one.append(i)
cnt_max = len(one)

for x in reversed(one):
  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:
  print(one)

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 ^ m[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:

N = int(input())

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


for i in range(N):

    cnt = 1
    summ = 0
    flag = True

    while (i + 1) * cnt <= N:

        summ += a[(i + 1) * cnt -1]
        cnt += 1

    if summ % 2 != a[i]:
        flag = False
        break
        #print (i+1,"はみたさない")

    else:
        pass
        #print (summ,a[i],"でおｋ")

if flag :
    

    #print (lis)

    print (sum(a))

    ans = ""

    for i in range(len(a)):
        if a[i] == 1:
            ans += str(i+1) + " "

    print (ans[:-1])

else:
    print (-1)

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(i) for i in input().split()]
C=[[0]*2 for _ in range(n)]
for i in reversed(range(n)):
  if A[i]==1:    
    if 2*(i+1)<=n and C[2*(i+1)-1][1]==1:
      C[i][1]=1
    else:
      C[i][0]=1
      C[i][1]=1
  else:
    if 2*(i+1)<=n and C[2*(i+1)-1][1]==1:
      C[i][0]=1
Ans1=0
Ans2=[]
for i in range(n):
  if C[i][0]==1:
    Ans1+=1
    Ans2.append(i+1)
if Ans1==0:
  print(0)
else:
  print(Ans1)
  print(*Ans2)

Submission status: Wrong Answer

Solution code:
# ABC134d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = [-1]
a.extend(list(map(int, input().split())))
ans = [0]*(n+1)


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

s = ""
c = 0
for i in range(n+1):
    if (ans[i] == 1):
        c += 1
        s += str(i)
print(c)
if(c != 0):
    print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

b_list = [0]*(N//2)+a_list[N//2:]
for i, a in enumerate(range(N//2)):
    j = N//2 - i

    j_list = []
    k = j
    while(1):
        j = j + k
        if j > N:
            break
        else:
            j_list.append(j)

    s = 0
    for j in j_list:
        s += b_list[j-1]

    if s % 2 == a_list[k-1]:
        b_list[k-1] = 0
    else:
        b_list[k-1] = 1
if len([str(i+1) for i, b in enumerate(b_list) if b == 1]) == 0:
    print(0)
else:
    print(' '.join([str(i+1) for i, b in enumerate(b_list) if b == 1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N + 1)
for i in range(N, 0, -1):
  j = i * 2
  s = 0
  while (j <= N):
    s += B[j]
    j += i
  B[i] = (s + A[i]) % 2
print(sum(B))
if sum(B) > 1:
  ans = ''
  for i in range(1, N + 1):
    if B[i] == 1:
      ans += str(i) + ' '
  print(ans.strip())

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = copy.deepcopy(A)

if max(A) > 1:
	print("-1")
else:
	for i in range(N // 2, 0, -1):
		total = 0
		for j in range(2 * i, N + 1, i):
			total += A[j]
		if total % 2 != A[i]:
			B[i] = 1
		else:
			B[i] = 0
			
	print(sum(B))
	for i in range(len(B)):
		if B[i] == 1:
			print(i, end = " ")

Submission status: Wrong Answer

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

for i in range(1, N+1):
  sum_ = 0
  for j in range(1, N//i+1):
    sum_ += a_list[i*j-1]
    sum_ %= 2
  if sum_ != a_list[i-1]:
    print(-1)
    exit()

for i, a in enumerate(a_list):
  if a == 1:
    ans += str(i+1) + " "
print(sum(a_list))
if ans:
  print(ans[:-1])

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)
    print(len(B))
    for b in B:
        print(b, end=' ')
    print()

main()

Submission status: Wrong Answer

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

N = i_inpl()
A = l_inpl()

ans = [0] * N
flag = True
for i in range(N)[::-1]:
    cnt = N//(i+1)
    if cnt == 1:
        if A[i] > 1:
            flag = False
            break
        else:
            ans[i] = A[i]
    else:
        tmp = 0
        for j in range(1, cnt+1):
            tmp += ans[j*(i+1)-1]
        if tmp == A[i]:
            ans[i] = 0
        if tmp == A[i]-1:
            ans[i] = 1
        else:
            flag = False
            break

if flag:
    print(sum(ans))
    l = []
    for ind, i in enumerate(ans):
        if i != 0:
            l.append(str(ind+1))
    if sum(ans) != 0:
        print(" ".join(l))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
B=[]
for i in range(n,0,-1):
    if n//i>1:
        l=n//i
        cnt=0
        for k in range(2,l+1):
            cnt+=a[i*k-1]
        if cnt%2!=a[i-1]:
            B.append(str(i))
    else:
        if a[i-1]==1:
            B.append(str(i))

print(len(B))
if len(B)>0:
    for i in range(len(B)):
        B[i]=str(B[i])
    print(' '.join(B))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(_) for _ in input().split()] 
b = [-1] * N

for i in reversed(range(N)):
    b[i] = (sum(b[0::(i+1)]) -b[i] + a[i]) % 2

print(sum(b))

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list=[9]
a_list += list(map(int, input().split()))

ans_list=[0]*(n+1)
output=[]
for i in range(n,0,-1):
  siji=a_list[i]
  num=n//i
  tmp=0
  for j in range(1,num):  
    tmp+=ans_list[i*num]
  if tmp%2==siji:
    ans_list[i]=0
  else:
    ans_list[i]=1
    output.append(i)
print(sum(ans_list[1:]))
for i in range(len(output)):
    if i == len(output)-1:
      print(output[i])
    else:
      print(output[i],end=" ")

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
# N = 2*10**5
# a = [0 for i in range(N)]

fail = False
r = [0 for i in range(N)]
for i in range(N)[::-1]:
  tmpsum = 0
  for t in range(2,(N//(i+1))+1):
#     print(f"  {t*(i+1)}")
    tmpsum += a[(i+1)*t-1]
  diff = a[i]-tmpsum
#   print(diff)
  if diff == 1:
    r[i] = 1
  elif diff == 0:
    r[i] = 0
  else:
    fail = True
    break

if fail:
  print(-1)
else:
  print(sum(r))
  result = []
  for i in range(N):
    if r[i]==1:
      result.append(i+1)
  if len(result) > 0:
    print(" ".join(map(str,result)))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[2]*n
for i in range(n,0,-1):
    if n//i==1:b[i-1]=a[i-1]
    else: b[i-1]=(sum(b[2*i-1::i])//2)^a[i-1]
print(sum(b))
for i in range(n):
    if b[i]==1:print(i+1,end=' ')

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil

n= int(sys.stdin.readline())
a= [ int(x) for x in sys.stdin.readline().split() ]
check= [ [] for _ in range(n) ] 
last= n+1
for i in range(1,n):
    j= ceil(n/(i+1))
    check[i]= [ k for k in range(j,last) ]
    if j==2: break
    last = j
#
ans= [ 0 ] * n
for i in range(n):
    if not check[i]: continue
    if i==1:
        for j in check[i]: ans[j-1]= a[j-1]
        continue
    #
    for j in check[i]:
        s= 0
        for k in range(2*j,n,j): s+= ans[k-1]
        ans[j-1] = ( a[j-1] + s ) % 2
#
s = sum(ans)
a0= ( a[0] + s ) % 2
m= s+a0
print( m )
if m>0:
    if a0: print( 1,end=" " )
    for i in range(1,n):
        if ans[i]: print( i+1,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_A = 0
        count_B = 0
        for m in range(i, N, i + 1):
            count_A += a[m]
            count_B += b[m]
        t = count_A % 2
        if count_B > t:
            print(-1)
            sys.exit()
        else:
            if t == 1:
                b[i] = 1

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=[int(i) for i in input().split()]
C=[[0]*2 for _ in range(n)]
for i in reversed(range(n)):
  if A[i]==1:    
    if 2*(i+1)<=n and C[2*(i+1)-1][1]==1:
      C[i][1]=1
    elif 2*(i+1)<=n and C[2*(i+1)-1][1]==0:
      C[i][0]=1
      C[i][1]=1
  else:
    if 2*(i+1)<=n and C[2*(i+1)-1][1]==1:
      C[i][0]=1
Ans1=0
Ans2=[]
for i in range(n):
  if C[i][0]==1:
    Ans1+=1
    Ans2.append(i+1)
if Ans1==0:
  print(0)
else:
  print(Ans1)
  print(*Ans2)

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)
  for i in range(N):
    if cnt[i] == 1:
      print(i+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 > 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))
for i in range(N):
    if C[i] == 1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n
cn = [0] * n
dn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    if (n//(j+1)<1):
        bn[j] = ai[j]
    else:
        bn[j] = (cn[j] + ai[j]) % 2

    if bn[j] == 1:
        for k in range(0,((j+1)//2)+1):
            if (j+1)%(k+1) == 0:
                cn[k] += 1

m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")

print(bn)

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[0] = (al ^ m[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:
n = int(input())
a = list(map(int,input().split()))
b =[0]*n
count = 0
ans = []

for i in reversed(range(n)):
  if n/2 < i :
    tmp = 2
    sum_num = 0
    while (tmp*(i+1) - 1) <= n:
      sum_num += 1 if b[tmp*(i+1)-1] == 1 else 0
      
    b[i] = 0 if sum_num %2 == 0 else 1
  else:
    b[i] = a[i]
  
  if b[i] == 1:
    count += 1
    ans.append(str(i+1))
    

print(count)
print(' '.join(ans))

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)

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:
N = int(input())
a = list(map(int, input().split()))

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

a.reverse()
check = [0 for _ in range(N + 1)]
ball = 0
for i in range(N):
  if check[N - i] % 2 != a[i]:
    ball += 1
    div = make_divisors(N - i)
    for d in div:
      check[d] += 1

print(ball)
for i in range(ball):
  print(1, end = "")
  if i != ball - 1:
    print(" ", end = "")
  else:
    print()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

MOD = 2  # type: int

def solve(N: int, A: "List[int]"):
    ans = []
    for i in range(N,0,-1):
        c = 0
        for j in range(2,N + 1):
            if i * j <= N:
                if A[i*j-1] == 1:
                    c += 1
            else:
                break
        if A[i-1] == 0:
            if c % 2 == 1:
                ans.append(str(i))
        else:
            if c % 2 == 0:
                ans.append(str(i))

    print(len(ans))
    if len(ans):
        print(" ".join(ans))


    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# ABC134d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = [-1]
a.extend(list(map(int, input().split())))
ans = [0]*(n+1)


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

s = ""
c = 0
for i in range(n+1):
    if (ans[i] == 1):
        c += 1
        s += str(i)
print(c)
print(s)

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
# N = 2*10**5
# a = [0 for i in range(N)]

fail = False
r = [0 for i in range(N)]
for i in range(N)[::-1]:
  tmpsum = 0
  for t in range(2,N//(i+1)):
#     print(f"  {t*(i+1)}")
    tmpsum += a[(i+1)*t-1]
  diff = a[i]-tmpsum
#   print(diff)
  if diff == 1:
    r[i] = 1
  elif diff == 0:
    r[i] = 0
  else:
    fail = True
    break

if fail:
  print(-1)
else:
  print(sum(r))
  result = []
  for i in range(N):
    if r[i]==1:
      result.append(i+1)
  if len(result) > 0:
    print(" ".join(map(str,result)))

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
	b.append(0)
for i in reversed(range(1,n+1)):
	j = copy.deepcopy(i)
	j -= 1
	sums = 0
	for k in range(int(n/i)):
		s = k*i
		sums += b[s]
	if(sums%2 == a[j]):
		b[j] = 0
	else:
		b[k] = 1

ans = []
anstext = ''
for i in reversed(b):
	if(i!=0):
		ans.append(i)
		anstext = anstext + str(i) + ' '
print(len(ans))
if(len(anstext)!=0):
	print(anstext[:-2])

Submission status: Wrong Answer

Solution code:
import math


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

    # divisors.sort()
    return divisors


N = int(input())
As = list(map(int, input().split(" ")))
As = [0] + As
kosu = [0] *(N+1)

anss = []
bs  = [0] *(N+1)
for i in range(N,N//2,-1):
    if As[i] == 0:
        bs[i] =0
    else:
        bs[i] = 1

for i in range(N// 2, 0, -1):
    temp = 0
    # print(i)
    for k in range(2,N):
        if i * k > N:
            break
        if bs[i * k] == 1:
            temp += 1
    if As[i] % 2  != temp %2:
        bs[i] = 1
print(bs.count(1))
for i,num in enumerate(bs):
    if num == 1:
        print(i)
# print(M)
# for i in ans:
#     print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = [0 for _ in range(N)]
half = int(N / 2) + 1
s = 0
hako = []
if N % 2 == 0:
    half = int(N / 2)

for i in reversed(range(N)):
    if i+1 >= half:
        if A[i] == 1:
            ans[i] = 1
            s += 1
            hako.append(i+1)
    else:
        cur = (i+1)*2
        tmp = 0
        while cur <= N:
            if ans[cur-1] == 1:
                tmp += 1
            cur += i+1
        if tmp % 2 != A[i]:
            ans[i] = 1
            s += 1
            hako.append(i+1)

print(s)
if len(hako) > 0:
    print(*hako)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
if n==1:
  print(1)
  print(l[0])
elif n%2==1:
  m=0
  ans=[]
  for i in range(1,n+1):
    c=n//i
    r=0
    for j in range(1,c+1):
      r+=l[j*i-1]
    if r%2==1:
      m+=1
      ans.append(str(i))
  print(m)
  print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
boxes = [0] * n
amari = list(map(lambda x: int(x), input().split()))


# boxes の うち c の倍数の要素を足し合わせて2で割った余りを返す
def box_count(boxes, c):
    counter = 0
    for i in range(0, len(boxes), max(c-1, 1)):
        if i == 0:
            continue
        else:
            counter += boxes[i]
    return counter % 2
        

ballbox = ''   
# 後ろから決めていく
for i in range(n):
    if box_count(boxes, n - i) == 1:
        boxes[n - i - 1] = 1 - amari[n - i - 1]
    else:
        boxes[n - i - 1] = 0 + amari[n - i - 1]

    if boxes[n - i - 1] == 1:
        ballbox += str(n - i) + ' '

print(sum(boxes))
print(ballbox)

Submission status: Wrong Answer

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

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

    return divisors

for i in range(n - 1, -1, -1):
    ind = make_divisors(i + 1)
    if num[i] // 2 == a[i]:
        continue
    else:
        for j in ind:
            num[j] += 1
box = [num[i] > 0 for i in range(n)]
print(box.count(True))
ans = [x + 1 for x in range(n) if box[x]]
print(*ans)

Submission status: Wrong Answer

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

ball = [0]*(n+1)
for j in range(n//2+1, n):
    ball[j] = a[j-1]
for i in range(n//2, 0, -1):
    summ = 0
    for k in range(2, n+1):
        if i*k > n:
            break
        else:
            summ += a[i*k-1]
    if a[i-1] == (summ%2):
        ball[i] = 0
    else:
        ball[i] = 1

print(sum(ball))
if sum(ball) > 0:
    ans = []
    for l in range(1, n+1):
        if ball[l] == 1:
            ans.append(l)
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    for i in range(n // 2, 1, -1):
        cnt = 0
        for j in range(n // i, 1, -1):
            if A[i] != (len([1 for k in range(i, n + 1, j) if A[k] == 1]) & 1):
                A[i] = 1 - A[i]
                cnt += 1
                if cnt > 1:
                    print(-1)
                    return
    if A[1] != (sum(A) & 1):
        A[1] = 1 - A[0]
    print(sum(A))
    print(*list(A[i] for i in range(1, n + 1) if A[i]))
solve()

Submission status: Wrong Answer

Solution code:

N = int(input())

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


for i in range(N):

    cnt = 1
    summ = 0
    flag = True

    while (i + 1) * cnt <= N:

        summ += a[(i + 1) * cnt -1]
        cnt += 1

    if summ % 2 != a[i]:
        flag = False

if flag :
    

    #print (lis)

    print (sum(a))

    ans = ""

    for i in range(len(a)):
        if a[i] == 1:
            ans += str(i+1) + " "

    print (ans[:-1])

else:
    print (-1)

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 = sum([ans[j] for j in range(num * 2, n, num)]) % 2

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=a.count(1)
b=[i for i in a if i==1]
print(c)
print(' '.join(str(x) for x in b))

Submission status: Wrong Answer

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <20/Jul/2019 06:14:55 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = get_array()
    d = {}
    i = 1
    op = []
    while i != n + 1:
        if arr[i - 1] == 1:
            if i not in d:
                d[i] = 1
                op.append(1)
            i += 1
            continue
        cnt = 0
        for j in range(i, n + 1, i):
            if arr[j - 1] == 1:
                if j not in d:
                    d[j] = 1
                    op.append(1)
                cnt += 1
        if cnt % 2 == 1:
            print(-1)
            return
        i += 1
    print(len(op))
    print(*op)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in reversed(range(1,N+1)):
    if sum(a[i::i])%2 != 1:
        a[i] = 0

print(sum(a))
for i,j in enumerate(a):
    if j:
        print(i, end=" ")

Submission status: Wrong Answer

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

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

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


m = 0
ans = []
for i in range(1,len(b)):
    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())
nums = input().split(" ")
a = [int(nums[i])for i in range(N)]
b = [0 for i in range(N)]
count = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        b[i] = 1
        count+=1
        for j in range(1, i//2+1, 1):
            a[i] = 1 - a[i]

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