参考:http://www.cnblogs.com/Jadon97/p/9383027.html

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #define N 2005
  5. using namespace std;
  6. int n,m,t;
  7. char tu[N][N];
  8. void test()
  9. {
  10. int i;
  11. for (i=;i<n;i++)
  12. {
  13. for (int j=;j<m;j++)
  14. {
  15. printf("%c",tu[i][j]);
  16. }
  17. printf("\n");
  18. }
  19. }
  20. void solve()
  21. {
  22. int i,p=,q=,r=,ra=n-,c=,ca=m-,flag=;//从外围向内遍历找到不对称的一行
  23. for (r=;r<ra;r++,ra--)
  24. {
  25. for (i=;i<m;i++)
  26. {
  27. if (tu[r][i]!=tu[ra][i])//用全局变量flag可以退出多重循环~
  28. {
  29. flag=;
  30. break;
  31. }
  32. }
  33. if (flag)
  34. {
  35. break;
  36. }
  37. }
  38. if (r>=ra)//全对称的情况
  39. {
  40. r--;
  41. }
  42. flag=;
  43. for (c=;c<ca;c++,ca--)
  44. {
  45. for (i=;i<n;i++)
  46. {
  47. if (tu[i][c]!=tu[i][ca])
  48. {
  49. flag=;
  50. break;
  51. }
  52. }
  53. if (flag)
  54. {
  55. break;
  56. }
  57. }
  58. if (c>=ca)
  59. {
  60. c--;
  61. }
  62. printf("%d\n",r*c);
  63.  
  64. }
  65. int main()
  66. {
  67. // freopen("总结.txt","r",stdin);
  68. while (scanf("%d",&t)!=EOF)
  69. {
  70. while (t--)
  71. {
  72. scanf("%d %d",&n,&m);
  73. int i;
  74. for (i=;i<n;i++)
  75. {
  76. scanf("%s",&tu[i]);
  77. getchar();
  78. }
  79. // test();
  80. solve();
  81. }
  82. }
  83.  
  84. return ;
  85. }

牛客网暑期ACM多校训练营(第四场) F的更多相关文章

  1. 牛客网 暑期ACM多校训练营(第二场)A.run-动态规划 or 递推?

    牛客网暑期ACM多校训练营(第二场) 水博客. A.run 题意就是一个人一秒可以走1步或者跑K步,不能连续跑2秒,他从0开始移动,移动到[L,R]的某一点就可以结束.问一共有多少种移动的方式. 个人 ...

  2. 牛客网 暑期ACM多校训练营(第一场)A.Monotonic Matrix-矩阵转化为格子路径的非降路径计数,Lindström-Gessel-Viennot引理-组合数学

    牛客网暑期ACM多校训练营(第一场) A.Monotonic Matrix 这个题就是给你一个n*m的矩阵,往里面填{0,1,2}这三种数,要求是Ai,j⩽Ai+1,j,Ai,j⩽Ai,j+1 ,问你 ...

  3. 2018牛客网暑期ACM多校训练营(第二场)I- car ( 思维)

    2018牛客网暑期ACM多校训练营(第二场)I- car 链接:https://ac.nowcoder.com/acm/contest/140/I来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 ...

  4. 牛客网暑期ACM多校训练营(第一场) - J Different Integers(线段数组or莫队)

    链接:https://www.nowcoder.com/acm/contest/139/J来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048 ...

  5. 牛客网暑期ACM多校训练营(第九场) A题 FWT

    链接:https://www.nowcoder.com/acm/contest/147/A来源:牛客网 Niuniu has recently learned how to use Gaussian ...

  6. 牛客网暑期ACM多校训练营(第九场)D

    链接:https://www.nowcoder.com/acm/contest/147/D来源:牛客网 Niuniu likes traveling. Now he will travel on a ...

  7. 牛客网暑期ACM多校训练营(第二场)B discount

    链接:https://www.nowcoder.com/acm/contest/140/B来源:牛客网 题目描述 White Rabbit wants to buy some drinks from ...

  8. 2018牛客网暑期ACM多校训练营(第一场)D图同构,J

    链接:https://www.nowcoder.com/acm/contest/139/D来源:牛客网 同构图:假设G=(V,E)和G1=(V1,E1)是两个图,如果存在一个双射m:V→V1,使得对所 ...

  9. 牛客网暑期ACM多校训练营(第二场) I Car 思维

    链接:https://www.nowcoder.com/acm/contest/140/I来源:牛客网 White Cloud has a square of n*n from (1,1) to (n ...

  10. 牛客网暑期ACM多校训练营(第二场) D money 思维

    链接:https://www.nowcoder.com/acm/contest/140/D来源:牛客网 White Cloud has built n stores numbered from 1 t ...

随机推荐

  1. Selenium2学习(十二)-- alert\confirm\prompt

    前言 不是所有的弹出框都叫alert,在使用alert方法前,先要识别出到底是不是alert.先认清楚alert长什么样子,下次碰到了,就可以用对应方法解决. alert\confirm\prompt ...

  2. February 26 2017 Week 9 Sunday

    There is only one happiness in life, to love and be loved. 生命中只有一种幸福,爱与被爱. Some one told me that hea ...

  3. SQA和测试规程

    SQA *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; ...

  4. 如何在Chrome development tool里查看C4C前台发送的请求细节

    我们可以在Chrome development tool的network tab里观察到从前台UI发送到后台的HTTP请求: 更多Chrome Development Tool的使用工具请查看我的博客 ...

  5. IOS NSLayoutConstraint 页面布局(通过代码添加约束)

    #import "ViewController.h" @interface ViewController () @property (nonatomic, strong) UIVi ...

  6. 漫谈C++:良好的编程习惯与编程要点(转载)

    这个博主写的文章真是细腻,全面,严谨,应当多读几回 原文http://www.cnblogs.com/QG-whz/p/5517643.html 阅读目录 以良好的方式编写C++ class Clas ...

  7. pthread 的几个结构体

    http://blog.csdn.net/yangzhongxuan/article/details/7397139 /* Copyright (C) 2002,2003,2004,2005,2006 ...

  8. 2018.12.26 Mac下的Eclipse在编辑Spring配置文件xml时自动提示类class包名配置

    1.先查看下自己的Eclipse是什么版本,步骤如下: 2.选择Install New Software 3.输入网址 http://dist.springsource.com/release/TOO ...

  9. Google TensorFlow 学习笔记一 —— TensorFlow简介

    "TensorFlow is an Open Source Software Library for Machine INtenlligence" 本笔记参考tensorflow. ...

  10. 数据库——MySQL——数据类型

    详细的看后面给的链接,我只是挑了一部分:http://www.runoob.com/mysql/mysql-data-types.html 在之前说了MySQL的存储引擎.它决定了表的类型,而表内存放 ...