牛客网暑期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 ...
随机推荐
- day2-基础 变量,判断,循环
1.第一个程序 print ("Hello World!") 输出: 1 Hello World 2.第一个变量 a = ( print (a) 输出: Hello World 3 ...
- OpenGL总结
最近2D转向3D,也从固定管线转到了可编程管线,有些细节的东西记录一下. Geometry Shader Geometry Shader从Vertex Shader中获取数据,向Fragment Sh ...
- 在已有软件加壳保护 下实现 Inline hook
如写的不好请见谅,本人水平有限. 个人简历及水平:. http://www.cnblogs.com/hackdragon/p/3662599.html 正常情况: 接到一个项目实现对屏幕输出内容的获取 ...
- OC 枚举
void test() { // 定义一种枚举类型 enum Season {spring, summer, autumn, winter}; // 定义一个枚举变量s enum Season s = ...
- Type Syntax error, insert ")" to complete Expression
今天倒持了 几个小时! 愣是 没有明确 ,为什么我的JSP的第一行没有代码? 还是报错! 错误是: Description Resource Path Location Type Sy ...
- pytorch 反向梯度计算问题
计算如下\begin{array}{l}{x_{1}=w_{1} * \text { input }} \\ {x_{2}=w_{2} * x_{1}} \\ {x_{3}=w_{3} * x_{2} ...
- 【转】CommonJS,AMD,CMD区别
学得比较晕,再次看commonjs,amd, cmd时好像还是没完全弄清楚,今天再整理一下: commonjs是用在服务器端的,同步的,如nodejs amd, cmd是用在浏览器端的,异步的,如re ...
- POJ 1330 Nearest Common Ancestors 【LCA模板题】
任意门:http://poj.org/problem?id=1330 Nearest Common Ancestors Time Limit: 1000MS Memory Limit: 10000 ...
- vue---组件引入及使用的几种方式
在vue的项目开发过程中,基本都是基于组件化开发项目,总结下使用组件的几个点: 一.@符号的使用 在vue项目中 @ 符号代表的是根目录,即 src 目录. 二.组件的放置位置 在项目中,公用的组件放 ...
- nginx 图片,js,css等文件允许跨域
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { #允许跨域请求 add_header Access-Control-Allow-Ori ...