牛客网暑期ACM多校训练营(第四场) F
参考:http://www.cnblogs.com/Jadon97/p/9383027.html
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #define N 2005
- using namespace std;
- int n,m,t;
- char tu[N][N];
- void test()
- {
- int i;
- for (i=;i<n;i++)
- {
- for (int j=;j<m;j++)
- {
- printf("%c",tu[i][j]);
- }
- printf("\n");
- }
- }
- void solve()
- {
- int i,p=,q=,r=,ra=n-,c=,ca=m-,flag=;//从外围向内遍历找到不对称的一行
- for (r=;r<ra;r++,ra--)
- {
- for (i=;i<m;i++)
- {
- if (tu[r][i]!=tu[ra][i])//用全局变量flag可以退出多重循环~
- {
- flag=;
- break;
- }
- }
- if (flag)
- {
- break;
- }
- }
- if (r>=ra)//全对称的情况
- {
- r--;
- }
- flag=;
- for (c=;c<ca;c++,ca--)
- {
- for (i=;i<n;i++)
- {
- if (tu[i][c]!=tu[i][ca])
- {
- flag=;
- break;
- }
- }
- if (flag)
- {
- break;
- }
- }
- if (c>=ca)
- {
- c--;
- }
- printf("%d\n",r*c);
- }
- int main()
- {
- // freopen("总结.txt","r",stdin);
- while (scanf("%d",&t)!=EOF)
- {
- while (t--)
- {
- scanf("%d %d",&n,&m);
- int i;
- for (i=;i<n;i++)
- {
- scanf("%s",&tu[i]);
- getchar();
- }
- // test();
- solve();
- }
- }
- return ;
- }
牛客网暑期ACM多校训练营(第四场) F的更多相关文章
- 牛客网 暑期ACM多校训练营(第二场)A.run-动态规划 or 递推?
牛客网暑期ACM多校训练营(第二场) 水博客. A.run 题意就是一个人一秒可以走1步或者跑K步,不能连续跑2秒,他从0开始移动,移动到[L,R]的某一点就可以结束.问一共有多少种移动的方式. 个人 ...
- 牛客网 暑期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 ,问你 ...
- 2018牛客网暑期ACM多校训练营(第二场)I- car ( 思维)
2018牛客网暑期ACM多校训练营(第二场)I- car 链接:https://ac.nowcoder.com/acm/contest/140/I来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 ...
- 牛客网暑期ACM多校训练营(第一场) - J Different Integers(线段数组or莫队)
链接:https://www.nowcoder.com/acm/contest/139/J来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048 ...
- 牛客网暑期ACM多校训练营(第九场) A题 FWT
链接:https://www.nowcoder.com/acm/contest/147/A来源:牛客网 Niuniu has recently learned how to use Gaussian ...
- 牛客网暑期ACM多校训练营(第九场)D
链接:https://www.nowcoder.com/acm/contest/147/D来源:牛客网 Niuniu likes traveling. Now he will travel on a ...
- 牛客网暑期ACM多校训练营(第二场)B discount
链接:https://www.nowcoder.com/acm/contest/140/B来源:牛客网 题目描述 White Rabbit wants to buy some drinks from ...
- 2018牛客网暑期ACM多校训练营(第一场)D图同构,J
链接:https://www.nowcoder.com/acm/contest/139/D来源:牛客网 同构图:假设G=(V,E)和G1=(V1,E1)是两个图,如果存在一个双射m:V→V1,使得对所 ...
- 牛客网暑期ACM多校训练营(第二场) I Car 思维
链接:https://www.nowcoder.com/acm/contest/140/I来源:牛客网 White Cloud has a square of n*n from (1,1) to (n ...
- 牛客网暑期ACM多校训练营(第二场) D money 思维
链接:https://www.nowcoder.com/acm/contest/140/D来源:牛客网 White Cloud has built n stores numbered from 1 t ...
随机推荐
- Selenium2学习(十二)-- alert\confirm\prompt
前言 不是所有的弹出框都叫alert,在使用alert方法前,先要识别出到底是不是alert.先认清楚alert长什么样子,下次碰到了,就可以用对应方法解决. alert\confirm\prompt ...
- February 26 2017 Week 9 Sunday
There is only one happiness in life, to love and be loved. 生命中只有一种幸福,爱与被爱. Some one told me that hea ...
- SQA和测试规程
SQA *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; ...
- 如何在Chrome development tool里查看C4C前台发送的请求细节
我们可以在Chrome development tool的network tab里观察到从前台UI发送到后台的HTTP请求: 更多Chrome Development Tool的使用工具请查看我的博客 ...
- IOS NSLayoutConstraint 页面布局(通过代码添加约束)
#import "ViewController.h" @interface ViewController () @property (nonatomic, strong) UIVi ...
- 漫谈C++:良好的编程习惯与编程要点(转载)
这个博主写的文章真是细腻,全面,严谨,应当多读几回 原文http://www.cnblogs.com/QG-whz/p/5517643.html 阅读目录 以良好的方式编写C++ class Clas ...
- pthread 的几个结构体
http://blog.csdn.net/yangzhongxuan/article/details/7397139 /* Copyright (C) 2002,2003,2004,2005,2006 ...
- 2018.12.26 Mac下的Eclipse在编辑Spring配置文件xml时自动提示类class包名配置
1.先查看下自己的Eclipse是什么版本,步骤如下: 2.选择Install New Software 3.输入网址 http://dist.springsource.com/release/TOO ...
- Google TensorFlow 学习笔记一 —— TensorFlow简介
"TensorFlow is an Open Source Software Library for Machine INtenlligence" 本笔记参考tensorflow. ...
- 数据库——MySQL——数据类型
详细的看后面给的链接,我只是挑了一部分:http://www.runoob.com/mysql/mysql-data-types.html 在之前说了MySQL的存储引擎.它决定了表的类型,而表内存放 ...