Ambiguous Permutation Problem

Hello everyone. I tried the Ambiguous Permutation problem under the Easy category, and I’ve written a code that seems to be working perfectly but for some reason the website says it’s the wrong answer. Can someone please help me out in identifying what the problem is? The code is as follows:

#include

using namespace std;

int main()
{
int t = 0, n = 0;

cin >> t;

bool check[t];

for(int i = 0; i < t; i++)
{
	cin >> n;
	
	int a[n];

	for(int j = 0; j < n; j++)
		cin >> a[j];
	
	int b[n];

	for(int j = 0; j < n; j++)
	{
		b[a[j]-1] = j + 1;
	}

	for(int j = 0; j < n; j++)
	{
		if(a[j] == b[j])
			check[i] = true;
		else
			check[i] = false;
	}
}

for(int i = 0; i < t; i++)
{
	if(check[i] == true)
		cout << "ambiguous" << endl;
		
	else
		cout << "not ambiguous" << endl;
}

return 0;

}

As soon as you find a certain a[j] such that it is not equal to b[j], you must break from the loop after setting check[i] to false, as the value of check[i] may be set to true again, if the numbers after a[j] match with b[j].

Also, the input format is different from what you have used.

//