beginner… well, very basic mistake use different variable instead of “t”(which you reserv for test cases) in for loop. in your code:
for(i=1;i<=m;i++)
{
scanf("%d",&p); // you are using t here which is used to test cases.
a[p]=0; //use different variable let’s take ‘p’;
}
a[p] is error