Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.Scanner;
- public class Solution {
- static void transposition(char [][]mass){
- char temp;
- for(int i = 0; i < 10; i ++){// reverse
- for(int j = 0; j < 10; j ++){
- if(i <= j){
- temp = mass[i][j];
- mass[i][j] = mass[j][i];
- mass[j][i] = temp;
- }
- }
- }
- }
- static void reverseMass(char [][]mass){
- char [][] newMass = new char[10][10];
- for(int i = 0; i < 10; i ++){// reverse
- for(int j = 0; j < 10; j ++){
- newMass[i][j] = mass[9-j][i];
- }
- }
- }
- static int proverka_line(char [][]mass){
- int isRow = 0;
- int st_i, st_j;
- int countX, countP;
- for(int i = 0; i < 10; i ++){
- st_i = i;
- for(int j = 0; j < 6; j ++){
- st_j = j;
- countX = 0;
- countP = 0;
- for(int k = 0; k < 5; k ++){
- if(mass[st_i][st_j] == 'X'){
- countX++;
- }
- else if(mass[st_i][st_j] == '.'){
- countP++;
- }
- st_j++;
- }
- if(countX == 4 && countP == 1){
- isRow = 1;
- }
- }
- }
- return isRow;
- }
- static int proverka_diagonal(char [][]mass){
- int isRow = 0, first_i, first_j, countX, countP;
- for(int i = 4; i < 10; i ++){
- for(int j = 0; j < 6; j ++){
- first_i = i;
- first_j = j;
- countX = 0;
- countP = 0;
- for(int k = 0; k < 5; k ++){
- if(mass[first_i][first_j] == 'X'){
- countX++;
- }
- else if(mass[first_i][first_j] == '.'){
- countP++;
- }
- first_i--; first_j++;
- }
- if(countX == 4 && countP == 1){
- isRow = 1;
- }
- }
- }
- return isRow;
- }
- public static void main(String[] args) throws IOException {
- BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
- char [][]mass = new char[10][];
- for(int i = 0; i < 10; i ++){
- mass[i] = input.readLine().toCharArray();
- }
- Integer vert = 0, horiz = 0;
- int leftRightDiag = 0, rightLeftDiag = 0;
- for(int q = 0; q < 2; q ++){
- if(q == 0){ //horiz
- horiz = proverka_line(mass);
- leftRightDiag = proverka_diagonal(mass);
- }
- if(q == 1){ //vert
- reverseMass(mass);
- char [][] newMass = new char[10][10];
- for(int i = 0; i < 10; i ++){// reverse
- for(int j = 0; j < 10; j ++){
- newMass[i][j] = mass[9-j][i];
- }
- }
- vert = proverka_line(newMass);
- rightLeftDiag = proverka_diagonal(newMass);
- }
- }
- if(horiz == 1 || leftRightDiag == 1 || vert == 1 || rightLeftDiag == 1){
- System.out.println("YES");
- }
- else System.out.println("NO");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement