1559C - Mocha and Hiking - CodeForces Solution


constructive algorithms graphs *1200

Please click on ads to support us..

Python Code:

from collections import defaultdict
from bisect import bisect_left
for _ in range(int(input())):

    n=int(input())

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


    
    if l[-1]==1:
        ans=[]
        f=0
        for i in range(n):
            if l[i]==1 and f==0:
                ans.append(n+1)
                ans.append(i+1)
                f=1
            else:
                ans.append(i+1)

        if f==0:
            ans.append(n+1)
            ans.append(n)

        print(*ans)


    else:
        for i in range(1,n+2):
            print(i,end=" ")



Comments

Submit
0 Comments
More Questions

1726H - Mainak and the Bleeding Polygon
722A - Broken Clock
129B - Students and Shoelaces
697B - Barnicle
903D - Almost Difference
1443B - Saving the City
1215C - Swap Letters
1251C - Minimize The Integer
1494B - Berland Crossword
295A - Greg and Array
1433E - Two Round Dances
1612D - X-Magic Pair
41B - Martian Dollar
906C - Party
774F - Pens And Days Of Week
598B - Queries on a String
1303B - National Project
1303D - Fill The Bag
1198B - Welfare State
1739B - Array Recovery
1739C - Card Game
1739A - Immobile Knight
1739D - Reset K Edges
817B - Makes And The Product
1452C - Two Brackets
400B - Inna and New Matrix of Candies
870B - Maximum of Maximums of Minimums
1600E - Array Game
1149A - Prefix Sum Primes
277A - Learning Languages