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:
mod = 10**9 + 7
from collections import deque

def main():
    N = iip(False)
    A = iip(True)

    sum_ball = [0 for i in range(N)]
    result = []
    for i, need in reversed(list(enumerate(A))):
        #print(i, need)

        if sum_ball[i] == need:
            continue

        elif sum_ball[i] == need - 1:
            result.append(i+1)

            for j in range(1, int(i+1 ** 0.5)):
                if (i+1) % j == 0:
                    sum_ball[j] += 1
                    sum_ball[j] %= 2

        else:
            print("-1")
            exit()

    print(len(result))
    split_print_space(result)

#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))

def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        #print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r-l > 1:
        x = (l+r)//2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        #print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

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

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    B = [0] * N
    for i in reversed(range(N)):
        j = 1
        p = 0
        while True:
            n = j * (i + 1) - 1
            if n >= N:
                break
            p += B[n]
            j += 1
        if A[i] % 2 != p:
            B[i] += 1
    ans = sum([b > 0 for b in B])
    print(ans)
    if ans > 0:
        for i, b in enumerate(B):
            if b == 1:
                print(i + 1, end=' ')
        print('')


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

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

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    B = [0] * N
    for i in reversed(range(N)):
        j = 1
        p = 0
        while True:
            n = j * (i + 1) - 1
            if n >= N:
                break
            p += B[n]
            j += 1
        if A[i] != p:
            B[i] += 1
    ans = sum([b > 0 for b in B])
    print(ans)
    if ans > 0:
        for i, b in enumerate(B):
            if b == 1:
                print(i + 1, end=' ')
        print('')


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    PAL=[0 for i in range(M)]
    ANS=[]
    for i in reversed(range(M)):
        if (i+1)*2>M:
            if B[i]==1:
                ANS.append(i+1)
            PAL[i]+=B[i]
        else:
            if B[i]!=(PAL[i]%2):
                PAL[i]+=1
                ANS.append(i+1)
        for j in fact[i]:
                PAL[j-1]+=PAL[i]
        # print(PAL)
    print(len(ANS))
    print(' '.join(map(str,ANS)))

Submission status: Wrong Answer

Solution code:
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[2 for i in range(M)]
    for i in reversed(range(M)):
        if (i+1)*2>M:
            ANS[i]+=B[i]
            for j in fact[i]:
                ANS[j-1]+=ANS[i]
        else:
            if B[j]!=(ANS[j]%2):
                ANS[j]+=1
        # print(ANS)
    print(M)
    print(' '.join(map(str,ANS)))

Submission status: Wrong Answer

Solution code:
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[2 for i in range(M)]
    for i in reversed(range(M)):
        if (i+1)*2>M:
            ANS[i]=B[i]
            for j in fact[i]:
                ANS[j-1]+=ANS[i]
        else:
            if B[j]!=(ANS[j]%2):
                ANS[j]+=1
        # print(ANS)
    print(M)
    for ans in ANS:
        print(ans)

Submission status: Wrong Answer

Solution code:
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[0 for i in range(M)]
    for i in reversed(range(M)):
        if (i+1)*2>M:
            ANS[i]=B[i]
            for j in fact[i]:
                ANS[j-1]+=ANS[i]
        else:
            if B[j]!=(ANS[j]%2):
                ANS[j]+=1
        # print(ANS)
    for ans in ANS:
        print(ans)

Submission status: Wrong Answer

Solution code:
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[0 for i in range(M)]
    for i in reversed(range(M)):
        if (i+1)*2>M:
            ANS[i]=B[i]
            for j in fact[i]:
                ANS[j-1]+=ANS[i]
        else:
            if B[j]!=(ANS[j]%2):
                ANS[j]+=1
        # print(ANS)
    print(ANS)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[-1 for _ in range(n)]
for i in range(n):
  j=n-i
  if n//j<2:
    ans[j-1]=a[j-1]
  else:
    p=sum(a[2*j-1::j])
    ans[j-1]=abs(a[j-1]-p)
b=[0 for _ in range(sum(ans))]
i=0
#print(ans)#######
m=sum(ans)
for j in range(n):
  if ans[j]!=1 or ans[j]!=0:
    print(-1)
    exit()
  if ans[j]==1:
    b[i]=j+1
    i+=1

print(m)
print(*b)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[-1 for _ in range(n)]
for i in range(n):
  j=n-i
  if n//j<2:
    ans[j-1]=a[j-1]
  else:
    p=sum(a[2*j-1::j])
    ans[j-1]=abs(a[j-1]-p)
b=[0 for _ in range(sum(ans))]
i=0
#print(ans)
m=sum(ans)
print(m)
for j in range(n):
  if ans[j]!=1 or ans[j]!=0:
    print(-1)
    exit()
  if ans[j]==1:
    b[i]=j+1
    i+=1
print(*b)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[-1 for _ in range(n)]
for i in range(n):
  j=n-i
  if n//j<2:
    ans[j-1]=a[j-1]
  else:
    p=sum(a[2*j-1::j])
    ans[j-1]=abs(a[j-1]-p)
b=[0 for _ in range(sum(ans))]
i=0
print(ans)
m=sum(ans)
print(m)
for j in range(n):
  if ans[j]!=1 or ans[j]!=0:
    print(-1)
    exit()
  if ans[j]==1:
    b[i]=j+1
    i+=1
print(*b)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[-1 for _ in range(n)]
for i in range(n):
  j=n-i
  if n//j<2:
    ans[j-1]=a[j-1]
  else:
    p=sum(a[2*j-1::j])
    ans[j-1]=abs(a[j-1]-p)
b=[0 for _ in range(sum(ans))]
i=0
#print(ans)
m=sum(ans)
print(m)
for j in range(n):
  if ans[j]!=0 or ans[j]!=0:
    print(-1)
    exit()
  if ans[j]==1:
    b[i]=j+1
    i+=1
print(*b)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[-1 for _ in range(n)]
for i in range(n):
  j=n-i
  if n//j<2:
    ans[j-1]=a[j-1]
  else:
    p=sum(a[2*j-1::j])
    ans[j-1]=abs(a[j-1]-p)
b=[0 for _ in range(sum(ans))]
i=0
#print(ans)
m=sum(ans)
print(m)
for j in range(n):
  if ans[j]==1:
    b[i]=j+1
    i+=1
print(*b)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[-1 for _ in range(n)]
for i in range(n):
  j=n-i
  if n//j<2:
    ans[j-1]=a[j-1]
  else:
    p=sum(a[2*j-1::j])
    ans[j-1]=abs(a[j-1]-p)
b=[0 for _ in range(sum(ans))]
i=0
#print(ans)
m=sum(ans)
print(m)
for j in range(n):
  if a[j]==1:
    b[i]=j+1
    i+=1
print(*b)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while b <= N:
            cnt += B[b]
            b += b
        if not cnt % 2 == A[i]:
            B[i] = 1
        else:
            B[i] = 0
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    A_keys = A.keys()
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while b <= N:
            cnt += B[b]
            b += b
        if not cnt % 2 == A[i]:
            B[i] = 1

    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(n)[::-1]:
    cnt = sum(a[i::i+1])
    b[i] = cnt%2

c = 0
for i in b:
    if i != 0:
        c += 1

print(c)
str_b = []
for i in reversed(b):
    if i != 0:
        str_b.append(str(i))
print(' '.join(str_b))

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = []
    dp = [0]*n

    #iの倍数の箱を調べる
    for i in range(n, 0, -1):
        #調べる箱列挙
        for j in range(i, n+1, i):
            dp[i-1] += dp[j-1]
        dp[i-1] %= 2
        if dp[i-1] != a[i-1]:
            res.append(i)
            dp[i-1] += 1
            dp[i-1] %= 2

    if not 1 in a:
        print(0)
    else:
        if len(res)>0:
            print(len(res))
            print(*res)
        else:
            print(-1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = []
    dp = [0]*n

    #iの倍数の箱を調べる
    for i in range(n, 0, -1):
        #調べる箱列挙
        for j in range(i, n+1, i):
            dp[i-1] += dp[j-1]
        dp[i-1] %= 2
        if dp[i-1] != a[i-1]:
            res.append(i)
            dp[i-1] += 1
            dp[i-1] %= 2

    if not 1 in a:
        print(0)
    else:
        print(len(res))
        if len(res)>0:
            print(' '.join(map(str, res)))
        else:
            print(-1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = []
    dp = [0]*n

    def yakusuu(N):
        n = int(N**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N%i==0:
                res1.append(i)
                if N!=i**2:
                    res2.append(N//i)
        res2.reverse()
        return res1+res2

    for i in range(n):
        l = yakusuu(i+1)
        for j in l:
            dp[i] += dp[j-1]
        dp[i] %= 2
        if dp[i]!=a[i]:
            res.append(i+1)
            dp[i] = (dp[i]+1)%2

    if not 1 in a:
        print(0)
    else:
        print(len(res))
        if len(res)>0:
            print(' '.join(map(str, res)))



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = []
    dp = [0]*n

    def yakusuu(N):
        n = int(N**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N%i==0:
                res1.append(i)
                if N!=i**2:
                    res2.append(N//i)
        res2.reverse()
        return res1+res2

    for i in range(n-1, -1, -1):
        if (a[i]==1 and dp[i]==0) or (a[i]==0 and dp[i]==1):
            l = yakusuu(a[i])
            res.append(i+1)
            for j in l:
                dp[j-1] = (dp[j-1] + 1) % 2
        else:
            continue
    print(len(res))
    if len(res)>0:
        print(' '.join(map(str, res)))



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import ceil

N = int(input())
D = ceil(N/2)
A = [0] + [int(i) for i in input().split()]

boxes = [0] * (N+1) # 1-indexed

for i in range(D, N+1):
    boxes[i] = A[i]

for i in range(N-D, 0, -1):
    c = 0
    for j in range(i+i, N+1, i):
        if A[j]:
            c ^= 1
    if c==A[i]:
        boxes[i]=0
    else:
        boxes[i]=1

res = set()
for i in range(1, N+1):
    if boxes[i]:
        res.add(i)

print(len(res))
print(*res)

Submission status: Wrong Answer

Solution code:
from math import ceil

N = int(input())
D = ceil(N/2)
A = [0] + [int(i) for i in input().split()]

boxes = [0] * (N+1) # 1-indexed

for i in range(D, N+1):
    boxes[i] = A[i]

for i in range(N-D, 0, -1):
    c = 0
    for j in range(N, i, -i):
        if A[j]:
            c ^= 1
    if c==A[i]:
        boxes[i]=0
    else:
        boxes[i]=1

res = set()
for i in range(1, N+1):
    if boxes[i]:
        res.add(i)

print(len(res))
print(*res)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if n // i == 1:
        val[i - 1] = lis[i - 1]
    else:
        p = n // i
        a = 0
        for j in range(p):
            a += val[i * (j + 1) - 1]
        if a % 2 == lis[i - 1]:
            val[i - 1] = 0
        else:
            val[i - 1] = 1

t = sum(val) % 2
if lis[0] == t:
    print(*[i + 1 for i in range(n) if val[i] == 1], sep=" ")
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=np.array(list(map(int, input().split())))
ans=np.array([0]*N)

for i in range(N, 0, -1):
  if i>N//2:
    ans[i-1]=A[i-1]
  else:
    X=ans[list(range(2*i,N,i))].sum()
    if X%2==A[i-1]:
      ans[i-1]=0
    else:
      ans[i-1]=1
      
      
print(ans.sum())
for i,a in enumerate(ans):
  if a==1:
    print(i+1, end=" ")

Submission status: Wrong Answer

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

if sum(a) <= 0:
    print(0)
    exit()
print(1)
print(a.index(max(a)) + 1)

Submission status: Wrong Answer

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

for i in range(M):
    if sum(a) <= 0:
        print(0)
        exit()
    elif a[i] == 1:
        print(1)
        print(i + 1)

Submission status: Wrong Answer

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

boxes = [-1]*N
for i in range(N)[::-1]:
  s = sum(A[i::i+1])
  boxes[i] = s % 2

M = sum(boxes)
print(M)
if M != 0:
  print(*[i + 1 for i, j in enumerate(boxes) if j == 1], sep=" ")

Submission status: Wrong Answer

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

boxes = [-1]*N
for i in range(N)[::-1]:
  s = sum(A[i::i+1])
  boxes[i] = s % 2

M = sum(boxes)
print(M)
if M != 0:
  print(*boxes, sep=" ")

Submission status: Wrong Answer

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

boxes = [-1]*N
for i in range(N)[::-1]:
  s = sum(A[i::i+1])
  boxes[i] = s % 2

M = sum(boxes)
print(M)
if M != 0:
  print(boxes[i], sep=" ")

Submission status: Wrong Answer

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
N = int(input())
a = inputlist()
ans = [0]*(N+1)
flag = [0]*(N+1)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
for i in range(1,N):
    k = N+1-i
    d = N//k
    if d == 1:
        ans[k] = a[k-1]
        if a[k-1] == 1:
            li = factorization(k)
            for j in range(len(li)):
                x = li[j][0]
                if flag[x] == 1:
                    flag[x] = 0
                else:
                    flag[x] = 1
    else:
        if flag[k] == a[k-1]:
            ans[k] = 0
        else:
            ans[k] = 1
            lia = factorization(k)
            for k in range(len(lia)):
                y = lia[k][0]
                if flag[y] == 1:
                    flag[y] = 0
                else:
                    flag[y] = 1
suma = sum(ans)
if suma % 2 == a[0]:
    ans[1] = 0
else:
    ans[1] = 1
ansa = ans[1:]
count = 0
lis = []
for i in range(N):
    if ansa[i] == 1:
        count+=1
        lis.append(i+1)
if count == 0:
    print(0)
    exit()
print(count)
print(*lis)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 18:39:26 2020

@author: Kanaru Sato
"""

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

for i in range(0,n):
    givenindex = n-1-i
    given = givenindex+1
    givenl = []
    
    for j in range(1,n):
        if given*j <= n:
            givenl.append(given*j)
        else:
            break
        
    sum = 0
    for j in givenl:
        sum += ans[j-1]
        
    if sum%2 == a[givenindex]:
        ans[givenindex] = 0
    else:
        ans[givenindex] = 1

sum = 0
for i in range(n):
    sum = sum + ans[i]
print(sum)

filledbox = []
for i in range(n):
    if ans[i] == 1:
        filledbox.append(i+1)
tmp = "".join(map(str,filledbox))
print(tmp)

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,0,-1):
  b[i]=a[i]%2
  k=i
  for j in range(1,int(k**0.5)+1):
    if k%j==0:
      a[j]+=b[i]
      a[k//j]+=b[i]
l=[]
for i in range(1,n+1):
  if b[i]==1:
    l.append(i)
print(len(l))
print(*l)

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,0,-1):
  b[i]=a[i]%2
  k=i
  for j in range(1,int(k**0.5)+1):
    if k%j==0:
      a[j]+=b[i]
      a[k//j]+=b[i]
l=[]
for i in range(1,n+1):
  if b[i]==1:
    l.append(i)
print(len(l))
print(*l)

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,0,-1):
  b[i]=a[i]%2
  k=i
  for j in range(1,int(k**0.5)+1):
    if k%j==0:
      a[j]+=1
      a[k//j]+=1
l=[]
for i in range(1,n+1):
  if b[i]==1:
    l.append(i)
print(len(l))
print(*l)

Submission status: Wrong Answer

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

sum=0

for A in a:
    sum+=A

print(sum)

Submission status: Wrong Answer

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

if n % 2 == 0:
    upper = n / 2 - 1
else:
    upper = (n - 3) / 2

for i in reversed(range(n)):
    if i > upper:
        ans[i] = a[i]
    elif i == 0:
        if sum(ans) % 2 == 0:
            ans[i] = a[i]
        else:
            print('-1')
            exit()
    else:
        sum_i = 0
        p = i * 2
        while p <= n:
            sum_i += ans[p - 1]
            p += i
        if sum_i % 2 == 0:
            ans[i] = a[i]
        else:
            print(-1)
            exit()

ball_count = sum(ans)
print(ball_count)
if ball_count:
    print(''.join([str(i + 1) for i, a_i in enumerate(ans) if a_i]))

Submission status: Wrong Answer

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

if n % 2 == 0:
    upper = n / 2 - 1
else:
    upper = (n - 3) / 2

for i in range(n - 1, -1, -1):
    if i > upper:
        ans[i] = a[i]
    elif i == 0:
        if sum(ans) % 2 == 0:
            ans[i] = a[i]
        else:
            print('-1')
            exit()
    else:
        sum_i = 0
        p = i * 2
        while p <= n:
            sum_i += a[p - 1]
            p += i
        if sum_i % 2 == 0:
            ans[i] = a[i]
        else:
            print(-1)
            exit()

ball_count = sum(ans)
print(ball_count)
if ball_count:
    print(''.join([str(i + 1) for i, a_i in enumerate(ans) if a_i]))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

half = N // 2

ball = np.zeros(N, dtype=np.bool)
ball[half:] = A[half:]

for i in range(half - 1, -1, -1):
    a = A[i]
    cnt = np.count_nonzero(ball[:: i + 1]) % 2
    if a != cnt:
        ball[i] = True

ans = np.where(ball == True)[0]
print(len(ans))

if len(ans) > 0:
    print(" ".join([str(x+1) for x in ans]))