-
Notifications
You must be signed in to change notification settings - Fork 0
/
grguy.cpp
57 lines (47 loc) · 914 Bytes
/
grguy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<stdio.h>
#include<algorithm>
#include<string.h>
#define v 1000000
int min1(int a,int b)
{
return (a>b)?b:a;
}
int main()
{
int t ,i;
scanf("%d",&t);
while(t--)
{
char str[2][1000000];
scanf("%s %s",&str[0],&str[1]);
// printf("%s\n",str[0]);
// printf("%s",str[1]);
int x=strlen(str[0]);
// printf("%d",x);
int T[2][x+1];
T[0][0]=0;
T[1][0]=0;
for(i=1;i<x+1;i++)
{
if(str[0][i-1]=='.')
{
T[0][i]=min1(T[0][i-1],T[1][i-1]+1);
}
if(str[0][i-1]=='#')
{T[0][i]=v;}
//printf("%d\n",T[0][i]);
if(str[1][i-1]=='.')
{
T[1][i]=min1(T[1][i-1],T[0][i-1]+1);
}
if(str[1][i-1]=='#')
T[1][i]=v;
//printf("%d\n",T[1][i]);
}
int ans=min1(T[0][x],T[1][x]);
if(ans==v)
printf("No\n");
else
printf("Yes %d\n",ans);
}
return 0 ;}