Help me in solving BSCOST problem

My issue

My code

#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n,x,y;
	    scanf("%d %d %d",&n,&x,&y); int count0=0, count1=0;
	    char a[n];
	    scanf("%s",a);
	    for(int i=0; i<n; i++)
	    {
	        if(a[i]=='0')
	        count0++;
	        else 
	        count1++;
	    }
	    
	    if(count1==0 || count0==0)
	    printf("0\n");
	    else
	    printf("%d\n",x>y?y:x);
	}
	return 0;
}


Problem Link: BSCOST Problem - CodeChef

What’s wrong in this code?

The logic that I’ve used is, if all the characters are either 1 or 0, then tax would be zero.
Otherwise
the minimum of the two taxes would be the answer because incase x<y we can arrange the string as 000111 type such that there’s one 1 “01” combination and incase y<x, we can arrange it as 111000 type such that there’s only one “10” combination.

@sagunsingh
Applying the same logic, the following code worked for me.

I have used Python here but applied the same logic.

# cook your dish here
for _ in range(int(input())):
    n,x,y=map(int,input().split())
    s=input()
    c0=0
    c1=0
    for i in s:
        if(i=='0'):
            c0+=1
        elif(i=='1'):
            c1+=1
            
    if((c0==n)or(c1==n)):
        print(0)
    else:
        print(min(x,y))