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

×

array transform

include<stdio.h>

int main() { int f,i,j,k,l,m,n,p,t,q,r,c,z; scanf("%d",&t); for(q=0;q<t;q++) { f=1; z=0; scanf("%d %d",&n,&k); int a[n]; for(r=0;r<n;r++) { scanf("%d",&a[r]); if(a[r]==0) z++; } c=1; for(i=1;i<n;i++) { if(a[i]==a[i-1]) c++; else { k=a[i-1]; l=a[i]; break; } } if(c==1) { if(a[i+1]==k || a[i+1]==l) { if(a[i+1]==k) m=k; else m=l; } else f=0;

                   }
         else
           {
            for(p=i+1;p<n;p++)
            {if(a[p]!=a[i-1])
                {f=0;
                break;
                   }
               }
        }
               if(f==1 && z<2)
               printf("YES\n");

               else
            {  if(z==n-1)
               printf("YES\n");
               else
               printf("NO\n");
              }



   }
return 0;

}

asked 23 Feb '15, 10:13

sarique's gravatar image

1★sarique
-1119
accept rate: 0%

2

Paste your code in proper blocks with the link of question.

(23 Feb '15, 11:54) damn_me3★
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:

×334
×185
×135
×9

question asked: 23 Feb '15, 10:13

question was seen: 466 times

last updated: 23 Feb '15, 11:54