TEMPLELA - Wrong Answer

I am getting WA for this code, but it is correct for all sample cases. Can anyone help me out?
Also I am new to codechef so is there a way to fetch testcases?

for tc in range(int(input())):
    
    n = int(input())
    li = list(map(int,input().split(' ')))
    first_half = []
    second_half = []
    if li[0]==1 and li[-1]==1:
        mid = n//2 + 1
        first_half = li[:mid]
        second_half = li[mid-1:]
        for i in range(len(first_half)-1):
            if first_half[i+1] - first_half[i] == 1:
                flag = 0
            else:
                flag=1
                break
            second_half.reverse()
            if second_half[i] == first_half[i]:
                flag = 0
            else:
                flag = 1
            
        if flag ==0:
            print('yes')
        else:
            print('no')
    else:
        print('no')

No there is no way to fetch(view) test cases :slightly_smiling_face:.May be run your code with multiple test cases and check if it is giving correct output or not.

yep its correct for all as far as I can check. :\

If your program is absolutely correct then you will get an AC. Since your program is failing in few or multiple test cases you got WA .Hope you understand :slightly_smiling_face:.

yes, I understand that, AFAIK I cant see any holes in the logic. I can do this in some other way of course but getting to know where I am going wrong will help learn something new. Hence the discussion :slight_smile:

Generally put the question link as well, so that people can actually check your code.

Better post the link to the question also

Question link: TEMPLELA Problem - CodeChef

First bug; consider the testcase:

1
7
1 2 3 4 3 5 1

I suspect that there will be one more bug after you fix this :slight_smile:

2 Likes

makes sense will keep that in mind.

@everule1

thanks a lot. will check it out :slight_smile: