enter code here

#include<stdio.h>

int main()

{

int t,i,n,m,k,l,o,j;

scanf("%d",&t);

while(t–)

{

scanf("%d %d %d",&n,&m,&k);int x[m],y[k],c1=0,c2=n;

for(i=0;i<m;i++)

{

scanf("%d",&x[i]);

}

for(i=0;i<k;i++)

{

scanf("%d",&y[i]);

}

if(m<k)

{

l=m;o=k;

}

else

{ l=k;o=m;}

for(i=0;i<n;i++)

{

for(j=0;j<o;j++)

{

if(x[i]==y[j])

{

c1++;break;

}

```
}
for(j=0;j<o;j++)
{
if(i+1==x[j] || i+1==y[j])
{
c2--;break;
}
}
}
printf("%d %d\n",c1,c2);
}
}
```

I am getting the correct output for the question Version Control System but the judge is giving me a Wrong Answer.Please correct me where im wrong.Thanks a lot in advance.

I am not quite getting what you are doing here. BTW, for me your code is giving 5 1 for first test case in sample example while output should be 4 1. Btw, Here is part of logic what wrote during contest that day, Full code can be found here,

as N is very small here, <= 100. so I just made an array with all 0’s initially…

```
int ar[n];
for(int i=0; i less than n; i++){
ar[i]=0;
}
```

then marked 1 to all those elements which are 1 in first array.

```
for(int i = 0; i less than m; i++) {
int data;
cin data;
ar[data-1]=1;
}
```

And then just iterate through second array and checked which elements are in second array is marked 1, will be part of first answer. And marked these elements 1 too to find second answer.

```
int ans1=0;
for(int i=0; i less than k; i++){
int data;
cin data;
if(ar[data-1]==1){
ans1+=1;
}
ar[data-1]=1;
}
```

Now to find second answer I just iterated through marking array again and checked number of elements which are still all 0, to find second answer.

```
int ans2=0;
for(int i=0;i less than n;i++){
if(ar[i]==0){
ans2+=1;
}
}
print ans1, ans2
```

Hope this will help.

1 Like

Thank you so much.I really appreciate the help.Could you please tell me where i went wrong in my attempt?

Also,i updated my code and am getting outputs ‘4 1’ and ‘1 1’ as in the example.However,the judge still gives me a Wrong Answer.