You are not logged in. Please login at www.codechef.com to post your questions!

×

RAINBOW:Showing wrong answer even with correct output

import java.util.*; class RAINBOW { public static void main(String []args){ try{ Scanner in=new Scanner(System.in); int T=in.nextInt(); for(int g=0;g<T;g++){ int N=in.nextInt(); int op=0,t=0,l=0; int[] A=new int[N]; int[] num={1,2,3,4,5,6,7}; for(int a=0;a<N;a++){ A[a]=in.nextInt(); } if(N%2==0){ if(A[N/2]==7) op=0; else op++;

    }
    else {
        if(A[(N+1)/2]==7)
            op=0;
        else op++;
    }
    for(int x=0;x<N;x++){

            if((A[x]==8)||(A[x]==9)||(A[x]==10))
                t++;

        }
   if(t!=0){op++;}
    for(int i=0;i<N/2;i++){
        if((A[i+1]-A[i])!=0 || (A[i+1]-A[i])!=1)
            op=0;
        else op++;
    }
   for(int k=0;k<N/2;k++){
        if((A[k]<A[k+1]) || (A[k]==A[k+1]))
            l++;
        if(l==0)
            op++;
    }
    for(int w=0;w<N/2;w++){
        if((A[w]!=A[N-1-w]))
            op++;
    }
    if(op==0)
    System.out.println("yes");
    else System.out.println("no");
  }

    }catch(Exception e){return;}

}}

asked 24 Sep '17, 11:42

muneur's gravatar image

4★muneur
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×186
×139
×30
×29
×25
×2
×1
×1

question asked: 24 Sep '17, 11:42

question was seen: 189 times

last updated: 24 Sep '17, 11:42