7-2 Magic mirror and card drawing

Description

lately ,billow And his classmates fell in love with a game called Shenyuan , Because they all want to play the same role , So they all worked hard for it .

Because this game needs a lot of resources to draw cards , And you may not get the role you want , So for their own efforts are not in vain , They're looking for something else (xuan) by (xue) Method of . So they asked ws The children are dozing AC The magic mirror was borrowed from the dream . By saying a spell to this magic mirror, you can ensure that you will get it .

But because this role can only play its role at least twice , So their needs are more complex , Therefore, the spell to be recited will also be more complex . We can abstract the spell into n Line per line m Character matrix of characters . If this matrix is symmetric up and down , Then the magic mirror can ensure that the small guarantee is not crooked . If this matrix is left-right symmetric , Then the magic mirror can guarantee to draw another one after the bottom guarantee . If this matrix is centrosymmetric , Then the magic mirror can ensure that two stones can be drawn out before they are used up . Now? ,ws The child gave a magic spell , They want to know what effect this spell has .

Input

Enter two numbers in the first line n,m  Indicates the number of rows and columns  1≤n,m≤103

next n that 's ok , Each line m Characters , Representation character matrix . Only lowercase letters are guaranteed .

Output

output 1~3 that 's ok . If this character matrix is symmetrical up and down , output
"xiaobaodi!"( No quotation marks ). If this character matrix is left-right symmetric , output "dabaodi!"( No quotation marks ). If the center of this character matrix is symmetrical , output "wuhu!"( No quotation marks ). If multiple symmetries are satisfied , Press up and down , about , Sequential output of center . If not , output "***,tuiqian!"( No quotation marks ).

Sample

Input1
3 5 abcde fghij abcde
Output1
xiaobaodi!
Input2
5 5 abcde fghij klmno pqrst uvwxy
Output2
***,tuiqian!
Input3
4 4 aaaa aaaa aaaa aaaa
Output3
xiaobaodi! dabaodi! wuhu!
  Analyze it

Judge whether the matrix is left-right symmetry , Upper and lower symmetry , Centrosymmetry .

set up n that 's ok m column ( String group from str[0] Start input )

i Representative bank ,j Representative column

If the upper and lower parts are symmetrical, then

If left-right symmetry

If central symmetry

#include <stdio.h> #include <stdlib.h> #include<string.h> int main() { int
n,m,i,j,f1=1,f2=1,f3=1; char str[1000][1000]; scanf("%d %d",&n,&m);
for(i=0;i<n;i++) { scanf("%s",str[i]); } for(i=0;i<n/2;i++)// Judge upper and lower symmetry {
for(j=0;j<m;j++) { if(str[i][j]!=str[n-1-i][j]) { f1=0; break; } } }
for(i=0;i<m;i++)// Judge left-right symmetry { for(j=0;j<n/2;j++) { if(str[j][i]!=str[j][m-1-i]) {
f2=0; break; } } } for(i=0;i<n;i++)// Judge central symmetry { for(j=0;j<m;j++) {
if(str[i][j]!=str[n-1-i][m-1-j]) { f3=0; break; } } }
if(f1)printf("xiaobaodi!\n"); if(f2)printf("dabaodi!\n");
if(f3)printf("wuhu!\n"); if(f1==0&&f2==0&&f3==0) printf("***,tuiqian!\n");
return 0; }
This code can also be optimized , But there is no idea at present .

Technology