cleaning up problem showing wrong ans... please tell my mistake

beginner… well, very basic mistake use different variable instead of “t”(which you reserv for test cases) in for loop. in your code:
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