All Tracks Basic Programming Implementation Basics of Implementation Problem

Batman and Tick-tack-toe
Tag(s):

Ad-Hoc, Basic Programming, Implementation, Very-Easy

Problem
Editorial
Analytics

Batman has defeated Hugo Strange and now he is getting bored as there is too much peace in Gotham City.

To pass his time he used to play 4 X 4 field Tick-Tac-Toe. One Day While playing, Commissioner Gordan Called Batman and he had to leave immediately so he didnt finish the game. It was Batman's turn in the game when they left it. Find Out whether Batman could have won the game by making a single turn or not.

The rules of tic-tac-toe are as follows.

Before the first turn all the field cells are empty. The two players take turns placing their signs into empty cells (the first player places Xs, the second player places Os). The player who places Xs goes first, the another one goes second. The winner is the player who first gets three of his signs in a row next to each other (horizontal, vertical or diagonal).

Input:

The first line of each test case defines the number of test cases t. then the next 4 line t times gives the tic-tac-toe positions Each of these lines contains four characters. Each character is '.' (empty cell), 'x' (lowercase English letter x), or 'o' (lowercase English letter o). It is guaranteed that the position is reachable playing tic-tac-toe, and it is Batman's turn now (in particular, it means that the game is not finished). It is possible that all the cells are empty, it means that the Both Batman and Robin left without making single turn.

Output:

Print single line: "YES" in case Batman could have won by making single turn, and "NO" otherwise.

Constraints:

1<=t<=10

SAMPLE INPUT
3
xx..
.oo.
x...
oox.
o.x.
o...
.x..
ooxx
x..x
..oo
o...
x.xo
SAMPLE OUTPUT
YES
NO
YES
Explanation

In the first example of the 3 test cases Batman had two winning moves: to the empty cell in the left column and to the leftmost empty cell in the first row.

In the second It wasn't possible to win by making single turn

In the Third Batman could have won by placing X in the last row between two existing Xs.

Time Limit: 0.3 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala 2.11.8, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

IIIT Jabalpur

Challenge Name

Beginner Practice Round 1.0

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications