Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

rainbow problom(i am getting a wrong answer)

$
0
0

include<stdio.h>

include<string.h>

int main() { int T,i; scanf("%d",&T); for(i=0;i<T;i++) { int K,N,j,flag=0; scanf("%d",&N); int A[N]; for(j=0;j<N;j++) { scanf("%d",&A[j]); } for(j=0;j<N/2;j++) { if(A[j]!=A[N-j-1]) {

        flag=1;
        break;

    }
}
int count=1;
if(N%2==0)
{
for(j=0;j<N/2;j++)
{
    if(A[j]!=count)
    {
        count++;
        if(A[j]!=count)
        {
            flag==1;
        }
    }
}

} else { for(j=0;j<=(N/2);j++) { if(A[j]!=count) { count++; if(A[j]!=count) { flag=1; } } }

} if(flag==1) { printf("NO\n"); } if(flag==0) { printf("YES\n"); } } }


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>