What is the problem with this code in following solution

#include
#include
#include
using namespace std;
int main() {
int t;
cin>> t;
while( t–){
int a[1000], n;
cin>>n;
for ( int i = 0; i< n; i++){
cin>>a[i];
}
int maxi = 0;
queue q;
int i = 0, j = 1 ;
q.push(i);
while( j< n-1 ){
if( a[j-1] > a[j] && a[j] < a[j+1] ){
q.push(j);
}
else if( a[j-1] < a[j] && a[j] > a[j+1] ){
q.push(j);
}
j++;
}
q.push(j);

	int p = q.front();
	q.pop();
	int c = q.front();
	q.pop();
	if( a[c] > a[p]){
		//even index
		c = q.front();
		q.pop();
		while( !q.empty()){
			//cout<< max( maxi, abs(c - p))<<endl;
			maxi = max(maxi, abs(c- p)+1);
			p = c;
			q.pop();
			c = q.front();
			q.pop();
		}
		maxi = max( maxi, abs(c - p)+1);

	}
	else{
		//odd index
		while( !q.empty()){
			//cout<< max( maxi, abs(c - p))<<endl;
			maxi = max( maxi, abs(c - p)+1);
			p = c;
			q.pop();
			c = q.front();
			q.pop();
		}
		maxi = max( maxi, abs(c - p)+1);

	}
	cout<<maxi<<endl;
	
	
}
return 0;

}

@snatchit this question can be done using 2 arrays here refer this
(https://www.geeksforgeeks.org/maximum-length-bitonic-subarray/)