GRGUY: Need help in figuring out my mistake.

I am now trying to do it with the greedy approach as specified in editorial but something’s wrong . Please help me in figuring it out.

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

main(){
ll t;
cin>>t;
while(t--){
	string l1,l2;
	cin>>l1>>l2;
	ll l1l=l1.length(),l2l=l2.length(),res=0,i;bool q=-1;
	for(i=0;i<l1l;i++){
		if(l1[i]=='#'&&l2[i]=='#'){
			res=INT_MAX;break;
		}
		else if(l1[i]=='#'){
			if(q==1)
			res++;
			q=0;
		}
		else if(l2[i]=='#')
		{
			if(q==0)
			res++;
			q=1;
		}
	}
	if(res==INT_MAX)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl<<res<<endl;
	
}
return 0;
}
1 Like

LOL , I just did a very silly mistake , I just declared that q variable initialized with -1 as bool type insted of int. As , bool can only store 0/1 , I was getting WA :stuck_out_tongue:

1 Like

very good logic!

Thanks :).

//