Sichuan University offline programming competition question 2 :Peter Of X

  • Announcement company :
  • Yes   effect   period :
  • CSDN
  • 2014-09-27 to 2015-09-26
  • difficult   degree   etc.   level :
  • answer   topic   when   Long :
  • Programming language requirements :
  • 120 minute
  • C C++ Java C#
Topic details

Peter It's a little boy , He can't always recite 26 English letters . therefore , The tricky English teacher gave him a very strange assignment , The teacher gave him a lesson from 26 It's made up of two English letters N*N Matrix ( We promise N It must be an odd number ), Ask him if the pattern formed by this matrix is a standard “X”.

A standard X The definition of :1、 All elements on the diagonal are the same letter .2、 All non diagonal elements are the same letter , And the letters are different from the letters on the diagonal .

If it is, then output “YES”. Otherwise output “NO”.

Input description narration :

Multiple sets of test data ( The amount of data is 100 Within group ). The first line of each group of test data is an integer N(1<=N<=300), Represents the size of the table .

Here are N A line is a letter N*N Matrix .

Output description narration :

Input data for each group , Output one line “YES” or “NO”.

Answer notes

Input example :















Output example :




Answer key : Direct simulation ;

#include <iostream>
using namespace std;
#define MAX 300+1
int main(){
int n;
char map[MAX][MAX];
while (cin>>n){
for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
char a=map[0][0],b=map[0][1];
int flag=0;
if (a==b)
for (int i=0;i<n;i++){
for (int j=0;j<n;j++){
if (i==j||j==n-1-i){ // The inference on the diagonal
if (map[i][j]!=a){
if (map[i][j]!=b){
if (flag)
if (flag)
return 0;

Copyright notice : This article is the original article of the blogger , Blog , Without consent , Shall not be reproduced .

In Sichuan University's second champion game online programming :Peter Of X More articles about

  1. Based on the second Sudoku game , add to GUI Interface

    Advanced software engineering third assignment : Based on the second Sudoku game , add to GUI Interface .GUI The interface code is as follows : package firstGui; import java.awt.*; import java.awt.event. ...

  2. Reprint :[ turn ] How to learn well 3D Game Engine Programming

      [ turn ] How to learn well 3D Game Engine Programming Albert This post is gamengines from The game engine (Game Engine) This is a reprint of , But it's worth seeing . This article is dedicated to those hot-blooded youth who are not afraid of difficulties for game programming , its ...

  3. Algorithm and data structure (2)-- The third online programming competition of the heroes Association : How many? bing

    The review of basic knowledge is no longer written here , Can write some algorithm solution or read some related books notes . I did an algorithm problem today , From Microsoft Bing · The third online programming competition of the heroes Association : How many? bing? Made it out. ... But I don't know why the execution of the test case failed ...

  4. Open XML SDK Online programming hacker song

    2015 year 2 month 10 Japan -3 month 20 Japan , Kaiyuan society   member   Microsoft open technology ,GitCafe, Geek Academy " Open XML SDK  Online programming hacker song  ", To focus on developing productivity enhancing applications and services ...

  5. Netease cloud classroom _C++ Introduction to programming ( On )_ The first 5 unit : Frost sky race free – More about objects and classes _ The first 5 Unit work 【4】 - Online programming ( difficulty : difficult )

    The first 5 Unit work [4] -  Online programming ( difficulty : difficult ) view help  return   reminder : 1. This assignment belongs to Online Judge subject , After submission, the system will immediately judge . 2. Students can submit their answers before the deadline for homework , system ...

  6. [ios- Must see ] People should strive for self-improvement : Online programming learning websites from both sides of the Taiwan Straits and three places are searched [ turn ] When it comes to domestic online programming learning websites , Many people are dazed , Even for senior developers . In the eyes of many people , Even though ...

  7. Primary game plug-in programming windows Operation principle + Game assisted programming Game plug-in programming

    Explain game assisted programming in detail [ Catalog ] 1- What is? Windows API 2-Windows process 3-Windows  How memory works 4-windows  The concept of handle in 5-Windows Variable type of 6- Aided implementation ...

  8. c++ Learning game programming server notes ( One )TCP/IP

    1. c++ Game server programming c++ Very efficient operation 2. TCP Transmission control protocol IP Internet protocol Socket 3.Linux Wubantu open source third party Library BOOST 4.80% The game server uses C++ The biggest part of the workload is the specific games ...

  9. 【 note 】《DirectX 9.0 3D Game development programming foundation 》:Direct3D initialization

    Direct3D Initialization is roughly divided into 4 A step : 1. Get interface IDirect3D9 The pointer to .(Direct3DCreate9 Function call ). The interface user obtains the information of the physical hardware device in the system and creates the interface IDirect3DDev ...

Random recommendation

  1. SegmentControl Things that are troubling

    Everyone's life was hard . I know I'm humble , But I didn't slow down , On this road till death . Wish to walk with you . UISegmentControl summary UISegmentControl Is the segment selection control of the system , It has a simple and generous appearance ...

  2. Configuration file instance and cron Expression details

    from XML File creation job Latest version Support direct from xml File creation job , It's easy to use . For the format of the configuration file, please refer to the following example <?xml version="1.0" e ...

  3. [JSP] User registration

    //----------------------userRegister.jsp <%@ page contentType="text/html;charset=gb2312" ...

  4. cordova Compiler error :Execution failed for task &#39;:processDebugResources&#39;

    cordova Compiler error :Execution failed for task ':processDebugResources' The biggest culprit for this error is a Chinese named file , I don't know when I joined , I have written ...

  5. How to use nobody The user executes the command ?

    Recently logstash Use in nobody User start logstash, Think about it ,nobody User shell No /sbin/nologin Do you ? Can't log in to execute command ? So I took a look at its startup script , It's using other ways to get into ...

  6. 【mysql Create user | Delete user | Modify user rights | Common commands 】

    Link to the original text : 1.       CREATE USER grammar : CREATE USER 'us ...

  7. String Of replace and replaceAll

    replace(CharSequence target, CharSequence replacement) here CharSequence It's an interface Implementation classes include CharBuffer, Segement ...

  8. How to tactfully judge whether the page is refreshed or closed , background :vue project , demand : Close page , Next time, go straight to the landing page

    There's a demand in recent projects : When closing the window of the current system , Log out , Because if you don't log out, there may be a security risk , I mean, actually , Don't lend the computer to others if you have nothing to do. Remember to lock the screen when you leave the station alive , In fact, we set up cookie Of expiration time , After that ...

  9. send out http Requested method

    stay http/1.1 Agreement , Defined 8 Sending http Requested method get post options head put delete trace connect patch. according to http The original design of the protocol , No ...

  10. SQL There are three types of submitted data

    Insert in database . When deleting and modifying operations , Only when the transaction is committed to the database can it be completed . SQL There are three types of statement commit data : Explicitly commit . Implicit and automatic submission . [1] Explicitly commit Explicitly commit . The box COMMIT Command to complete the submission directly . ...