New Year Chaos

  • + 0 comments

    can somebody please tell me what is wrong with this code? int main(){ int t; cin >> t; while(t--) { int n,temp,bribes=0; int flag=0; cin >> n; int count_swap[n]; vector q(n); for(int q_i = 0;q_i < n;q_i++) { cin >> q[q_i];

        }
        for(int i=0,j=i+1;i<n,j<n;i++,j++)
        {
    
                 count_swap[i]=0;
                if(q[i]<q[i+1])
                   { temp=q[i];
                    q[i]=q[i+1];
                    q[i+1]=temp;
                    bribes++;
    
    
                    count_swap[q[i]]=count_swap[q[i]]+1;
                   } 
    
        }
    
    
        for(int i=0;i<n;i++)
            {
          if(count_swap[i]>2)  
            flag=1;
    
        }
        if(flag==1)
        cout<<"Too chaotic"<<endl;
        else cout<<bribes<<endl;
        }
    
    
    
    return 0;
    

    }