Help me in solving BROKPHON problem

My issue

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);  
cin.tie(NULL); 
       
       int t;
       cin>>t;
       
       while(t--){
           int n=0;
           cin>>n;
           
           int count=0;
           
           int A[n];
           
           for(int i=0;i<n;i++){
               cin>>A[i];
           }
           
           for(int i=0;i<n;i++){
             
               if(A[i]==A[0]) count++;
               else{break;}
           }
           cout<<n-count<<endl;
           
           
       }



	return 0;
}

Problem Link: BROKPHON Problem - CodeChef

Your last if-statement is wrong. You’re counting the correct message by comparing it to the first message and then substracting it to N-number but I think you misunderstand the problem.

I suggest you read again the problem statement and understand it before trying to solve it. your last else-statement is also a problem cause you are using break which just stop the program once it encounter a message that is not equal to the first message. I think this is also because you didn’t understand the problem.

P.S. This is my first time replying here so I don’t know if I should give you the correct solution or just tell your problem.