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

b=[-1]*N
b[N-1]=a[N-1]
for i in range(N-1)[::-1]: #N=4なら 2,1,0
    sum_count = N // (i+1)
    if sum_count==1:
        b[i]=a[i]
    else:
        sum1=0
        for j in range(sum_count-1):
            sum1 = sum1 + b[(i+1)*(j+1)]
        sum1 = sum1 % 2
        b[i]=a[i]+ sum1%2

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

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+1])
  if b%2 == a[i] :
    for j in range(N):
      if a[j] == 1:
        l.append(str(j+1))
    if len(l)!= 0:
      print(' '.join(l))
      print(len(l))
    else:
      print(len(l))
    break
  else:
    count += 1
if count == N :
  print(-1)

Submission status: Wrong Answer

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

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

cnt = a.count(1)
if cnt <= n:
    print(cnt)
    ans = []
    for i in range(n):
        if a[i] == 1:
            ans.append(i+1)
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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

def find_baisu(a):
    j = 2
    ret = []
    while(a*j <= N):
        ret.append(a*j)
        j += 1
    return ret
    
for i in range(N):
    num = N-i
    baisu = find_baisu(num)
    baisu_box_sum = 0
    for j in range(len(baisu)):
        baisu_box_sum += box[baisu[j]]
    if(baisu_box_sum % 2 == a[num]):
        box[num] = 0
    else:
        box[num] = 1

M = 0
ans = ''
for i in range(N):
    if(box[i] == 1):
        M += 1
        ans += str(i) + ' '

print(M)
print(ans)

Submission status: Wrong Answer

Solution code:
print(1)
print(1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
box = {}
ans = ""
count = 0
for i in range(N):
    box[i+1] = 0

for i in range(N, 0, -1):
    a = 0
    for j in range(N//i):
        a += box[(j+1)*i]
    if a % 2 != A[i-1]:
        box[i] = 1
        count+=1
        ans += str(i) + " "

print(count)
if ans:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N =int(input())
As = [int(x) for x in input().split()]
res = [0]*(N)

for i in range(N-1,N//2,-1):
    res[i] = As[i]
for i in range(N//2,0,-1):
    res[i] = (As[i]+sum(res[0::(i+1)]))%2
res[0] = (As[0]+sum(res[1:]))%2
print(" ".join(map(str,res)))

#1 0 0

Submission status: Wrong Answer

Solution code:
n = int(input())
array = list(map(int, input().split()))
count = 0
result = []
for i in range(n):
    if array[i] == 1:
        count += 1
        result.append(str(i + 1))
if count == 0:
    print(0)
else:    
    print(count)
    print(" ".join(result))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


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


def solve(N: int, a: "List[int]"):

    b = [0]*N
    for i in range(N-1, -1, -1):
        if b[i] % MOD != a[i]:
            b[i] = 1-b[i] % MOD
        if b[i] % MOD == 1:
            # print(make_divisors(i))
            for d in make_divisors(i)[: -1]:
                b[d] += 1
    # for i in range(N//2-1, -1, -1):
    #     if a[i] != b[i] % 2:
    #         b[i] += 1
    # b[0] = a[0]-b[0]
    # print(b)

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    return


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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

ball = [0] * (N+1)

for i in range(len(a)-1, 0, -1):
	if i > N // 2:
		ball[i] = a[i]
	else:
		tmp = 0
		for x in range(i, N+1, i):
			# print(x)
			if x == i:
				continue
			tmp = tmp ^ ball[x]
		ball[i] = tmp ^ a[i-1]
		# print("i",i)
		# print(tmp, a[i-1])
# print(ball)
print(sum(ball))
for i, j in enumerate(ball):
	if j == 1:
		print(i, end=" ")
print()

Submission status: Wrong Answer

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

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

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

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):
		total = 0
		for j in range(2 * i, N + 1, i):
			total += A[j]
		if total % 2 != A[i]:
			B[i] = 1
			
	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())
aaa = list(map(int, input().split()))
aaa = [0] + aaa
for i in range(n // 2, 1, -1):
    b = 0
    j = i * 2
    while n >= j:
        b ^= aaa[j]
        j += i
    aaa[i] ^= b

if sum(aaa) % 2 == aaa[1]:
    ans = [i for i, b in enumerate(aaa) if b]
    print(len(ans))
    print(*ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(i) for i in input().split()]

    c = [0] * n
    b = []

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

    print(len(b))
    print(*b)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

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


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        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")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
D={}
ans=""
M=0
for i in range(N):
    if N//(N-i)==1:
        a=A[N-i-1]
        D[N-i]=a
        if a==1:
            M+=1
            ans=ans+str(N-i)+" "
    else:
        a=N//(N-i)
        memo=0
        for j in range(1,a):
            memo+=A[(N-i)*(j+1)-1]
        if memo%2==A[N-i-1]:D[N-i]=0
        else:
            D[N-i-1]=1
            M+=1
            ans=ans+str(N-i)+" "
ans=ans[:-1]
print(M)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
B = [0]*N
for i in range(N-1,-1,-1):
    k = sum(B[i::i+1])
    if k%2!=A[i]:
        B[i]=1
        ans+=1
print(ans)
print(*[1 for i in range(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 i > N // 2:
        b[i-1] = a[i-1]
    else:
        si = 0
        for j in range(i+i, N, i):
            si += b[j-1]
        if si % 2 == a[i-1]:
            b[i-1] = 0
        else:
            b[i-1] = 1

if a == b:
    print(sum(b))
    for i in range(N):
        if b[i] == 1:
            print(i+1 ,end=' ')
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = [0]*n
for i in range(n):
    if (n-i)*2 > n:
        l[n-i-1] = a[n-i-1]
    else:
        count = n//(n-i)
        count1 = 0
        for x in range(2,count+1):
            count1 = l[((n-i)*x)-1] + count1
        if (count1)%2 == a[n-i-1]:
            l[n-i-1] = 0
        else:
            l[n-i-1] = 1
print(sum(l))
if sum(l) > 0:
    for i in l:
        print(i, end=" ")

Submission status: Wrong Answer

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


B = []
checked = [0 for _ in range(N)]
for i in range(N, 0, -1):
    num = N // i
    a = A[i-1]
    for j in range(1, num):
        a += checked[j*i-1]
    if a % 2 == 1:
        B.append(i)
        checked[i-1] = 1
print(len(B))
print(' '.join([str(b) for b in B]))

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+1])
  if b%2 == a[i] :
    for j in range(N):
      if a[j] == 1:
        l.append(str(j+1))
    if len(l)!= 0:
      print(' '.join(l))
      print(len(l))
    else:
      print(len(l))
    break
  else:
    count += 1
if count ==1 :
  print(-1)

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=ans1+str(ans[j])+" "
    else:
        ans1=ans1+str(ans[j])
print(cnt)
if len(ans1)>0:
    print(ans1)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    results = []
    for i, a in enumerate(a_s):
        if a == 1:
            for result in results:
                if (i+1) % result == 0:
                    print(-1)
                    quit()
            results.append(i+1)
    print(len(results))
    if results:
        results = list(map(str, results))
        print(' '.join(results))


if __name__ == '__main__':
    main()

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]
        for j in range(2,int(i**0.5+1+10**-9)):
            if i%j==0:
                c[i]=1-c[i]
                c[i//j]=1-c[i//j]

s=sum(b)
if s%2!=a[1]:
    b[1]=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:
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(count)
    else :
        flag = 1
        break
if flag==1:
    print(-1)
else:
    print(len(out_list))
    for i in out_list:
        try:
            print(*i)
        except:
            break

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
c=[]
cnt=0
for i in range(1,N+1)[::-1]:
  if sum(b[::i])%2 != a[i-1]:
    a[i-1]=1
    c.append(i)
    cnt+=1
print(cnt)
if len(c)>0:
  print(*c,sep='\n')

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
a_list = [0] + list(map(int, input().split()))
result = True
answer_box = [0] * (N+1)
inboxes = []
for i in range(N, 0, -1):
    last_i = i * (N // i)
    count = 0
    for j in range(last_i, i-1, -i):
        print(N, i, j)
        count += answer_box[j]
    if (count % 2) != a_list[i]:
        answer_box[i] = 1
        inboxes.append(i)

if(result):
    print(len(inboxes))
    if(len(inboxes) > 0):
        print(" ".join(str(e) for e in inboxes))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <20/Jul/2019 06:06:49 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()
    i = 1
    ans = [-1] * (n + 1)
    d = {}
    op = []
    while i != n:
        if ans[i] != -1:
            if ans[i] % 2 != arr[i - 1]:
                print(-1)
                return
        ans[i] = arr[i - 1]
        for j in range(i, n, i):
            ans[j] = arr[j - 1]
        if ans[i] == 1:
            op.append(1)
        i += 1

    print(len(op))
    if len(op) > 0:
        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:
from sys import stdin

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

    ball = 0
    ans = []
    for i in range(N - 1, -1, -1):
        if A[i] % 2 != ball % 2:
            ball += 1
            ans.append(i + 1)
    print(ball)
    if ans:
        print(*ans)

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

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

n=int(input())
C=[0]*n
A=[int(i) for i in input().split()]
for i in range(n):
  if A[i]==1:    
    for d in make_divisors(i+1):
      C[d-1]^=1
Ans1=sum(C)
print(Ans1)
if Ans1!=0:
  Ans2=[]
  for i in range(n):
    if C[i]==1:
      Ans2.append(i+1)
  print(*Ans2)

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]
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:
n = int(input())
aa = list(map(int, input().split()))
aa = [-1] + aa[:]
ans = []
for i in range((n + 1) // 2, 0, -1):
    s = 0
    for ii in range(i * 2, n + 1, i):
        s += aa[ii]
    if aa[i] == s % 2:
        aa[i] = 0
    else:
        aa[i] = 1
        ans.append(i)
print(len(ans))
if ans:
    print(*ans, sep="\n")

Submission status: Wrong Answer

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

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

for i in range(n):
    if a_list[-i-1] == 1:
        b_list.append(n-i)
        for j in make_divisors(i):
            a_list[j-1] = abs(a_list[j-1]-1)

b_list.reverse()
x = len(b_list)
print(x)
if x != 0:
    print(*b_list)

Submission status: Wrong Answer

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

ans = set()
cnt = [0] * (n + 1)

for i in range(n, 0, -1):
    if cnt[i] % 2 != a[i] % 2:
        ans.add(i)
        cnt[i] += 1
        j = i
        while j <= n:
            cnt[j] += 1
            j += i

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
c = [0 for i in range(n)]
for i in range(n, 0, -1):
  t = a[i-1]
  if t==1:
    c[i-1] ^= 1
  while i%2==0:
    i //= 2
    if (t==1 and a[i-1]==0) or (t==0 and a[i-1]==1):
      c[i-1] ^= 1
      t ^= 1
    else:
      break
  if i!=1:
    if (t==1 and a[0]==0) or (t==0 and a[0]==1):
      c[0] ^= 1
#print(a)
#print(c)
tt = sum(c)
if tt%2!=a[0]:
  print(-1)
else:
  print(tt)
  if tt==0:
    exit()
  ans = []
  for i in range(n):
    if c[i]==1:
      ans.append(i+1)
  print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]+[int(_) for _ in input().split()]
ans=[]
for i in range(N,0,-1):
    bai=N//i
    if A[i]!=sum(A[i*b] for b in range(2,bai+1))%2:
        ans+=[i]
print(len(ans))
print(*ans[::-1],sep=' ')

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))
Bs = [0] * N

for i in range(N - 1, -1, -1):
    if i >= (N - 1) // 2:
        Bs[i] = As[i]
    else:
        Bs[i] = abs(As[i] - (sum(Bs[2 * i + 1::i + 1]) % 2))

M = sum(Bs)
print(M)
if M != 0:
    print(" ".join(str(i+1) for i, b in enumerate(Bs) if b == 1))

Submission status: Wrong Answer

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

b = [0] + [0] * (N//2) + a[(N//2):]
M = a[(N//2):].count(1)

for i in range(N//2, 0, -1):
    total = sum(b[i::i])
    x = (total + a[i]) % 2
    M += x
    b[i] = x
print(M)

for i in range(M):
    print(1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

N = int(input())

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



lis = [-1] * N


for i in range(N):

    i = N-i
    cnt = 2
    summ = 0
    flag = True

    while i * cnt <= N:

        summ += lis[i * cnt -1]
        cnt += 1

    #print (a[i-1],summ)

    if a[i-1] == 0 and summ % 2 == 0:
        lis[i-1] = 0
        #print ("a")

    elif a[i-1] == 0 and summ % 2 == 1:
        flag = False

    elif a[i-1] == 1 and summ % 2 == 0:
        lis[i-1] = 1

    elif a[i-1] == 1 and summ % 2 == 1:
        flag = False

    if not flag:
        break

if flag:

    #print (lis)

    print (sum(lis))

    ans = ""

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

    print (ans)

else:
    print (-1)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
B = [0]*N
for i in range(N-1,-1,-1):
    k = sum(B[i::i+1])
    if k%2!=A[i]:
        B[k]=1
        ans+=1
print(ans)
print(*[1 for i in range(ans)])

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
if k == 0:
	print(0)
	exit()

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])
mmm = m[1:]
print(len(mmm))
print(jo(mmm))

Submission status: Wrong Answer

Solution code:
N = int(input())
a_s = [None] + [int(elm) for elm in input().split(" ")]
bs = [None for _ in range(N+1)]

out_indexs = []
out_num = 0
for val in range(N, 0, -1):
    r = N // val
    tmp = [bs[val*i] for i in range(2, r)]
    #print(val, tmp)
    other_sums = sum(tmp) % 2
    if other_sums == a_s[val]:
        bs[val] = 0
    else:
        bs[val] = 1
        out_indexs.append(val)
        out_num += 1

print(out_num)
if out_num >= 1:
    print(" ".join(map(str, out_indexs)))

Submission status: Wrong Answer

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

b = [0] * N
for i in range(N-1, -1, -1):
    if i + (i+1) >= N:
        b[i] = a[i]
        continue
    s = 0
    k = i + (i+1)
    while k < N:
        s += b[i]
        k += (i+1)

    if s % 2 == a[i]:
        b[i] = 0
    else:
        b[i] = 1

print(b.count(1))
bv = []
for i, bi in enumerate(b):
    if bi == 1:
        bv.append(i+1)
if bv:
    print(' '.join(map(str, bv)))

Submission status: Wrong Answer

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

ans = [-1] * (N+1)
count = 0
for i in range(N, 0, -1):
    tmp = 0
    p = i
    p += p
    # print (p)
    while p < N:
        tmp += ans[p]
        p += p
    ans[i] = a[i] - (tmp%2)
    if ans[i] == 1:
        count += 1
# print (ans)
print (count)
for i in range(1, N + 1):
    if ans[i] == 1:
        print (i)

Submission status: Wrong Answer

Solution code:
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <20/Jul/2019 06:04:31 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()
    i = 1
    ans = [-1] * (n + 1)
    d = {}
    op = []
    while i != n:
        if ans[i] != -1:
            if ans[i] % 2 != arr[i - 1]:
                print(-1)
                return
        ans[i] = arr[i - 1]
        if ans[i] == 1:
            op.append(1)
        i += 1

    print(len(op))
    if len(op) > 0:
        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:
def main():
  n = int(input())
  a_list = list(map(int, input().split()))
  if not sum(a_list):
    print(0)
    return
  for i in range(1, n+1):
    if not i == 1:
      a = sum(a_list[1:][::i])
    else:
      a = sum(a_list[::i])
      
    if (a % 2) % i:
      print(-1)
      continue
    if not a:
      continue
    print(a)
    t = " ".join(str(a_list[x]) for x in range(a))
    if t:
      print(t)
      
main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]+[int(_) for _ in input().split()]
ans=[]
for i in range(N,0,-1):
    bai=N//i
    print(i,sum(A[i*b] for b in range(2,bai+1)))
    if A[i]!=sum(A[i*b] for b in range(2,bai+1))%2:
        ans+=[i]
print(len(ans))
print(*ans[::-1],sep=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
Bs = [-1] * N
for i in reversed(range(N)):
  a = As[i]
  r = 0
  for j in range(2,N):
    j2 = j*(i+1)-1
    if j2 >= N:
      break
    r += Bs[j2]
  b = (r+a)%2
  #print(i, a, r, b)
  Bs[i] = b
#print(Bs)
Cs = []
for i in range(N):
  if Bs[i] == 1:
    Cs.append(str(i+1))
print(len(Cs))
if len(Cs) > 0:
  print(" ".join(Cs))