Can anyone plz tell me what is wrong in this solution?

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int flag2=0;
int flag1=0;
ll func2(string s1,string s2,ll n)
{
	int count=0;
			ll i=0;
			while(i<n-1)
			{
				if(s2[i+1]=='#' && s1[i+1]=='#')
				{
					if(flag1==0)
					{
	
					flag2=1;
					cout<<"No"<<endl;
					break;
				}
				}
				else if(s2[i+1]=='#')
				{
					if(s1[i+1]=='.')
					{
						
						swap(s1,s2);
						count++;
						
					}
					else if(s1[i]=='.')
					{
						swap(s1,s2);
						count++;
					}
					i++;
				}
				else
				{
					i++;
				}	
			}
			return count;
}




ll func1(string s1,string s2,int n)
{
	ll count=0;
			ll i=0;
			while(i<n-1)
			{
				if(s1[i+1]=='#' && s2[i+1]=='#')
				{
					if(flag2==0)
					{
					flag1=1;
					cout<<"No"<<endl;
					break;
					}
				}
				else if(s1[i+1]=='#')
				{
					if(s2[i+1]=='.')
					{
							swap(s1,s2);
						count++;
						
					}
					else if(s2[i]=='.')
					{
							swap(s1,s2);
						count++;
					}
					i++;
				}
				else
				{
					i++;
				}	
			}
			return count;
			
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;
	while(t-->0)
	{
		string s1,s2;
		cin>>s1>>s2;
		ll n=s1.length();
		ll kk[n];
		ll kk1[n];
		int flag=0;
		for(ll i=0;i<n;i++)
		{
			if(s1[i]=='#' && s2[i]=='#')
			{
				flag=1;
				cout<<"No"<<endl;
				
				
			}
		}
		if(flag==0)
		{
	
		
		if(s1[0]=='.' && s2[0]=='#')
		{
			int value=func1(s1,s2,n);
			if(flag1==0)
			{
				
			cout<<"Yes"<<endl<<value<<endl;
		}
			
		}
		else if(s2[0]=='.' && s1[0]=='#')
		{
			int value=func2(s1,s2,n);
			if(flag2==0)
			{
			cout<<"Yes"<<endl<<value<<endl;
			}
		}
		else
		{
			ll value=min(func1(s1,s2,n),func2(s1,s2,n));
			if(flag1==0 && flag2==0)
			{
		
			cout<<"Yes"<<endl<<value<<endl;
		}
			
			
		}
	}
	
		
	}
		return 0;
	
}

The Problem is GRGUY problem**

Thanks

can you plz help me now

Provide Context -
i. Link to the problem statement , it makes it easier for people to read and understand the problem , get initial bearings , understand the sample input and you’ll get help faster
ii. Provide a brief write-up demonstrating what you’ve tried so far and what exactly you need help with , makes it so much better than a generic “Help Me! Fast”

How to indent

I would recommend this style

Additionally, you are outputting extra values, in all the testcases you got WA.
I simply counted the outputs and asserted it to be 1.
assert(); aborts the program if the condition is not satisfied.
https://www.codechef.com/viewsolution/32431158

1 Like