CodeForces - 404A(模拟题)

Valera and X

Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

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.

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:

  • on both diagonals of the square paper all letters are the same;
  • 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.

Help Valera, write the program that completes the described task for him.

Input

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.

Output

Print string "YES", if the letters on the paper form letter "X". Otherwise, print string "NO". Print the strings without quotes.

Sample Input

Input

5xoooxoxoxosoxoooxoxoxooox

Output

NO

Input

3wswswswsw

Output

YES

Input

3xpxpxpxpe

Output

NO

Source

Codeforces Round #237 (Div. 2)

题意:只有两种不同的字符,对角线一种,非对角线一种,判断对角线的所有字符是否一样,非对角线的所有字符是否一样。

#include <iostream>
using namespace std;
int main()
{
    int i,j,n;
    char c[305][305];
    cin>>n;
    for(i=0;i<n;i++)
    cin>>c[i];
    char tmp1=c[0][0];
    char tmp2=c[0][1];
    if(tmp1==tmp2)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    int flag=1;
    for(i=0;i<n;i++)
    {for(j=0;j<n;j++)
    {
        if(i==j||i+j==n-1)
        {
            if(c[i][j]!=tmp1)
            {
                flag=0;
                break;
            }
        }
        else
        {
            if(c[i][j]!=tmp2)
            {
                flag=0;
                break;
            }
        }if(!flag)
        break;
        }
    }
    if(flag)
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
    return 0;
}
时间: 2024-12-25 02:44:19

CodeForces - 404A(模拟题)的相关文章

CodeForces - 427B (模拟题)

Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of t

CodeForces - 404B(模拟题)

Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose

CodeForces - 200ACinema模拟题

CodeForces - 200A Cinema Time Limit: 1500MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The capital of Berland has the only movie theater in the country. Besides, it consists of only one room. The room is divid

Codeforces 48C The Race 模拟题

题目链接:点击打开链接 题意: 给定n个加油站,一辆车由A点跑到B点,每个100m有一个加油站,每开100m需要10升油. 在每个车站会检查一下油量,若车子若开不到下一个加油站则加x升油. 开始有x升油 下面给出加油的记录. 问下一次加油在哪一站.若答案唯一输出具体哪站. 油箱容量无限 思路: 水模拟.. #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h>

CodeForces 404A 手速题

//CodeForces 404A 1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "algorithm" 5 using namespace std; 6 char mat[310][310]; 7 int n; 8 bool check_1() 9 { 10 int i; 11 char c = mat[1][1]; 12

HDU 4028 The time of a day STL 模拟题

暴力出奇迹.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<queue> #include<set> #include<map> using namespace std; #define ll __int64 #define N 42 ll n,m,ans;

cf428c 模拟题

这题说的是给了 n个数然后又 k次 的交换任意位置的 数字的机会  计算最长的连续子序列的和 这要撸  模拟整个 过程 并不能就是算最长的递增序列 如果只是 找最长的 和序列的 话 会存在 很多问题 在替换的时候 每一个决策 都影响着 下一个决策  这样 存在谁与谁替换 这样的状态有 200!种    那就枚举每个区间这样就可以使得 我们所用替换方法得当  因为在替换中我们进行替换是对不同区间的 操作 比如 在替换序列之内的 数字的时候 其实操作的就是不同的区间 与外面的序列进行替换的时候 操作

TOJ1290 Poker Hands 模拟题

寒假期间抽空做的一道模拟题 难度不算大,把每种牌型分开处理,可以合并的步骤考虑合并. 代码比较丑陋,首次尝试Sport Programming的风格,结果搞了个不伦不类(手动笑哭) 1 #include <algorithm> 2 #include <bitset> 3 #include <cctype> 4 #include <complex> 5 #include <cstdio> 6 #include <cstring> 7 #

hdu 5641 King&#39;s Phone(暴力模拟题)

Problem Description In a military parade, the King sees lots of new things, including an Andriod Phone. He becomes interested in the pattern lock screen. The pattern interface is a 3×3 square lattice, the three points in the first line are labeled as