404A.md (1592B)
1 Source: https://codeforces.com/problemset/problem/404/A 2 3 A. Valera and X 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a test on alphabet today. At the test Valera got a square piece of squared paper. The length of the side equals *n* squares (*n* is an odd number) and each unit square contains some small letter of the English alphabet. 22 23 Valera needs to know if the letters written on the square piece of paper form letter "X". Valera's teacher thinks that the letters on the piece of paper form an "X", if: 24 25 * on both diagonals of the square paper all letters are the same; 26 * all other squares of the paper (they are not on the diagonals) contain the same letter that is different from the letters on the diagonals. 27 28 Help Valera, write the program that completes the described task for him. 29 30 Input 31 32 The first line contains integer *n* (3 ≤ *n* < 300; *n* is odd). Each of the next *n* lines contains *n* small English letters — the description of Valera's paper. 33 34 Output 35 36 Print string "YES", if the letters on the paper form letter "X". Otherwise, print string "NO". Print the strings without quotes. 37 38 Examples 39 40 Input 41 42 ``` 43 5 44 xooox 45 oxoxo 46 soxoo 47 oxoxo 48 xooox 49 ``` 50 51 Output 52 53 ``` 54 NO 55 ``` 56 57 Input 58 59 ``` 60 3 61 wsw 62 sws 63 wsw 64 ``` 65 66 Output 67 68 ``` 69 YES 70 ``` 71 72 Input 73 74 ``` 75 3 76 xpx 77 pxp 78 xpe 79 ``` 80 81 Output 82 83 ``` 84 NO 85 ```