What’s wrong with this code ? i’m getting WA , give me some inputs where my code goes wrong
link - https://pastebin.ubuntu.com/24738697/
thank you
1
3
*.*
...
Should give 1
Yours gives 0
thank you
for which input will my code produce wrong output plz help me,i have covered all cases still not getting after submitting several times thanks bro:)
My code gave correct output for as many inputs as I tried.
Here’s the solution : https://www.codechef.com/viewsolution/13960885
This is the code:
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
scanf("%d",&t);
while(t--)
{
int n, count=0, i, flag=0, mark=0, top=0, bottom=0;
scanf("%d",&n);
char str[2][n];
for(i=0; i<2; i++)
{
scanf("%s",&str[i]);
for(int j=0; j<n; j++)
if(str[i][j]=='*')
mark++;
}
if(mark==2)
{
printf("1\n");
continue;
}
for(i=0; i<2; i++)
for(int j=0; j<n; j++)
if(str[i][j]=='*')
{
flag++;
break;
}
if(flag==2)
count=1;
if(count==1)
for(int j=0; j<n-1; j++)
for(int k=j+1; k<n; k++)
{
if(str[0][j]=='*'&&top==0)
top=1;
if(str[1][j]=='*'&&bottom==0)
bottom=1;
if((str[0][j]=='*'&&str[0][k]=='*'&&top==1)||(str[1][j]=='*'&&str[1][k]=='*'&&bottom==1))
{
count++;
top=0;
bottom=0;
j=k-1;
break;
}
}
else
count=mark-1;
printf("%d\n",count);
}
return 0;
}
Could someone please tell which case did I miss?
Can anyone please tell me which testcase fails my code?
Solution link: https://ideone.com/AVh0zv
Thank you
Can any one please tell for which input my code is failing , i tried a lot but did not get a single failure in my code.
https://www.codechef.com/viewsolution/13954302
Can someone please tell what’s wrong with my code. I am getting WA.
My code-
https://www.codechef.com/viewsolution/13962047
@anuj_sharma 03
your output:-1
expected output:1
mine answer was coming on dev c++ but the ide gave WA…
#include<stdio.h>
#define P 100000
int main()
{
int t,h,v,n,i,j,s,k,f;
char c[2][P];
scanf("%d",&t);
while(t–)
{
h=0;
v=0;
scanf("%d",&n);
for(i=0;i<2;i++)
{
scanf("%s",&c[i]);
}
i=0;
for(j=0;j<n;j++)
{
if(c[i][j]==’’&&c[i+1][j]==’’)
{
h=1;
break;
}
}
i=0;
for(j=0;j<(n-1);j++)
{
if((c[i][j]=='*'&&c[i][j+1]=='*')||(c[1][j]=='*'&&c[1][j+1]=='*'))
v++;
}
i=0;
for(j=0;j<n;j++)
{
for(k=(j+2);k<(n-1);k++)
{
if(c[i][j]=='*'&&c[i][k]=='*')
{
if((j+1)!=k)
{
v++;
j=k-1;
break;
}
}
}
}
i=1;
for(j=0;j<n;j++)
{
for(k=1;k<n;k++)
{
if(c[0][j]=='*'&&c[i][k]=='*')
{
if(j!=k)
{
h=1;
f=7;
break;
}
}
}
if(f==7)
break;
}
s=v+h;
printf("%d\n",s);
}
return 0;
}
Can someone please let me know where my code is failing …???