Gravity Guy

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import java.io.

*;
import java.lang.*;
import java.util.*;
public class gravity_guy
{
public static void main(String[] args) throws InputMismatchException
{
Scanner x = new Scanner(System.in);
long t, i, j, n;
String s1, s2, s = "", sx = "", sy = "";
t = x.nextLong();
for(i = 1; i <= t; i ++)
{
n = 0;
s1 = x.nextLine();
s2 = x.nextLine();
if(s1.charAt(0) == '#' && s2.charAt(0) == '#')
System.out.println("NO");
else
{
if(s1.charAt(0) == '#')
{
s = s1;
sx = s2;
}
else
{
s = s1;
sx = s2;
}
for(j = 0; j < s.length() - 1; j ++)
{
if(s.charAt(j + 1) == '#' && sx.charAt(j + 1) == '#')
{
System.out.println("NO");
break;
}
else if(s.charAt(j + 1) == '#' && sx.charAt(j + 1) == '.')
{
sy = s;
s = sx;
sx = sy;
n ++;
}
else
continue;
}
if(j == s.length())
{
System.out.println("YES");
System.out.println(n);
}
}
}
}
}

You might also like