Ilya and tic-tac-toe game
time limit per test 2 second memory limit per test 256 megabytes
Ilya is an experienced player in tic-tac-toe on the 4×4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn’t finish the last game. It was Ilya’s turn in the game when they left it. Determine whether Ilya could have won the game by making single turn or not.
The rules of tic-tac-toe on the 4×4 field 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).

传送门:CF754B

Input

The tic-tac-toe position is given in four lines. 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 Ilya'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 friends left without making single turn.

Output

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

Sample Input

1
2
3
4
xx..
.oo.
x...
oox.

Sample Output

1
YES

题解

一开始还想dfs。。。自己好蠢= = 嵌在大图里暴力搜所有解就好了,心疼自己
## AC code:(不包含输入类)
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
import java.io.*;  
import java.util.*;
public class Main {
static char[][]maze;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
maze=new char[8][8];
for(int i=2;i<6;i++){
String s=sc.next();
for(int j=2;j<6;j++){
maze[i][j]=s.charAt(j-2);
}
}
boolean flag=false;
for(int i=2;i<6;i++){
for(int j=2;j<6;j++){
//horizontal
if(maze[i][j]=='.'&&maze[i][j+1]=='x'&&maze[i][j+2]=='x') flag=true;
if(maze[i][j]=='x'&&maze[i][j+1]=='.'&&maze[i][j+2]=='x') flag=true;
if(maze[i][j]=='x'&&maze[i][j+1]=='x'&&maze[i][j+2]=='.') flag=true;
//vertical
if(maze[i][j]=='.'&&maze[i+1][j]=='x'&&maze[i+2][j]=='x') flag=true;
if(maze[i][j]=='x'&&maze[i+1][j]=='.'&&maze[i+2][j]=='x') flag=true;
if(maze[i][j]=='x'&&maze[i+1][j]=='x'&&maze[i+2][j]=='.') flag=true;
//diagonalleftcross
if(maze[i][j]=='.'&&maze[i-1][j-1]=='x'&&maze[i+1][j+1]=='x') flag=true;
if(maze[i][j]=='x'&&maze[i-1][j-1]=='.'&&maze[i+1][j+1]=='x') flag=true;
if(maze[i][j]=='x'&&maze[i-1][j-1]=='x'&&maze[i+1][j+1]=='.') flag=true;
//rightcross
if(maze[i][j]=='.'&&maze[i-1][j+1]=='x'&&maze[i+1][j-1]=='x') flag=true;
if(maze[i][j]=='x'&&maze[i-1][j+1]=='.'&&maze[i+1][j-1]=='x') flag=true;
if(maze[i][j]=='x'&&maze[i-1][j+1]=='x'&&maze[i+1][j-1]=='.') flag=true;
}
if(flag==true) break;
}
if(flag==true) System.out.println("YES");
else System.out.println("NO");
}