WA in CHEF AND RECIPE

@durga_7 @rishup_nitdgp @rahulkiller26 @everule1
this is my code

Blockquote
#include
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,l=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];

   int vis[1001]={0},c=1;
   vis[a[0]]=1;
   for(int i=1;i<n;i++)
   {
    if(a[i]-a[i-1]==0)
    continue;
    else
    if(vis[a[i]]==1)
    c=0;
   
    vis[a[i]]++;
   }  
   
   int freq[1001]={0},unq[1001]={0};
   
   for(int i=0;i<n;i++)
    freq[a[i]]++;
     
    for(int i=0;i<n;i++)
     if(freq[i]>1)
      unq[freq[i]]++;

      int flag=1;
     for(int i=0;i<n;i++)
     if(unq[i]>1)
      {
          flag=0;
          break;
      }
      
    for(int i=1;i<n;i++)
    {
        if(a[i]!=a[i-1])
        l++;
    }
    if(l==n-1)
     flag=0;
   // cout<<"flag is "<<flag<<"  c is "<<c<<endl;
    if(flag==0||c==0)
     cout<<"NO"<<endl;
     else
     if(flag==1&&c==1)
     cout<<"YES"<<endl;
}

}

Kindly format your code or share a link to the submission.

@ameybhavsar thanks for replying

this is the link to my solution

https://www.codechef.com/viewsolution/33359650

and why others are not replying as it has 17 views but 1 reply???

The fact that you didn’t read the globally pinned post on how to ask questions kinda raises flags about the effort you’re going to make to get help, also most people don’t respond to posts asking for help no matter what.

Nonetheless. What is the point of lines 45-51?