I have written the following program for PERMUT2- ambiguous permutations

And I simply don’t understand why this code says wrong output on CodeChef, but runs fine on my PC…

#include

#include <malloc.h>

#include <stdio.h>

using namespace std;

int main() {

long int t, n;

int *permut, *inverse;

int ambFlag=1;

```
//cin>>t;
while (scanf("%d", &n) && n) {
//cin>>n;
//if (n==0) break;
permut=new int[n];
inverse=new int[n];
for (long int i=0; i<n; i++) {
cin>>permut[i];
if (n==1) {
ambFlag=1;
}
else {
inverse[permut[i]-1]=i+1;
}
}
if (n!=1) {
for (long int i=0; i<n; i++) {
if (permut[i]!=inverse[i]) {
ambFlag=0;
break;
}
}
}
if (ambFlag==0) cout<<"not ambiguous"<<endl;
else cout<<"ambiguous"<<endl;
delete [] permut;
delete [] inverse;
}
return 0;
```

}