So i have tried the Chef and rainbow array question. I do get correct answers for the given test cases on codeblocks, but when submitting codechef says wrong answer. Is something wrong with my logic? Thanks
Link to question: https://www.codechef.com/problems/RAINBOWA
My code:
#include<stdio.h>
int main(){
int i,j,t,n,count7,rem,status,midstat;
int count1,count2,count3,count4,count5,count6;
int a[100];
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d",&n);
count7=0;
midstat=1;
count6=0;
count5=0;
count4=0;
count3=0;
count2=0;
count1=0;
for(j=0;j<n;j++){
scanf("%d",&a[j]);
if(a[j]==7){
count7++;
}
}
rem=n-count7;
if(rem%2!=0||count7==0){
status=0;
}
else{
for(j=0;j<(rem/2);j++){
if(a[j]==a[n-1-j]){
midstat*=1;
}
else{
midstat*=0;
}
}
if(midstat==1){
for(j=0;j<rem/2;j++){
switch(a[j]){
case 1:count1++;
break;
case 2:count2++;
break;
case 3:count3++;
break;
case 4:count4++;
break;
case 5:count5++;
break;
case 6:count6++;
break;
}
}
if(count1>0&&count2>0&&count3>0&&count4>0&&count5>0&&count6>0){
status=1;
}
else{
status=0;
}
}
}
if(status==1){
printf("yes\n");
}
else{
printf("no\n");
}
}
}