计算机学院大学生程序设计竞赛(2015’12) 1006 01 Matrix
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
using namespace std; const int maxn=+;
char s[maxn][maxn];
int n,m;
int c[maxn][maxn];
int sum[*maxn][*maxn];
int ans[maxn]; int main()
{
int T;
//freopen("F:\\in.txt","r",stdin);
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&m);
memset(sum,,sizeof sum);
memset(ans,,sizeof ans);
// memset(c,0,sizeof c);
for(int i=;i<n;i++) scanf("%s",s[i]);
for(int i=;i<=n;i++) for(int j=;j<=n;j++) c[i][j]=s[i-][j-]-''; for(int i=;i<=*n;i++)
for(int j=;j<=*n;j++)
{
if(i>n||j>n)sum[i][j]=sum[i-][j]+sum[i][j-]-sum[i-][j-];
else sum[i][j]=sum[i-][j]+sum[i][j-]-sum[i-][j-]+c[i][j];
} for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(c[i][j]==) continue;
int left,right,mid;
int anslen;
left=;right=n;
while(left<=right)
{
mid=(left+right)/;
int s=sum[i+mid-][j+mid-]-sum[i+mid-][j-]-sum[i-][j+mid-]+sum[i-][j-];
if(s==mid*mid)
{
anslen=mid;
left=mid+;
}
else right=mid-;
}
ans[anslen]++;
}
} for(int i=n-;i>=;i--) ans[i]=ans[i]+ans[i+];
//for(int i=1;i<=n;i++) printf("%d %d\n",i,ans[i]); for(int i=;i<=m;i++)
{
int x;
scanf("%d",&x);
printf("%d\n",ans[x]);
} }
return ;
}
计算机学院大学生程序设计竞赛(2015’12) 1006 01 Matrix的更多相关文章
- hdu 计算机学院大学生程序设计竞赛(2015’11)
搬砖 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...
- 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排
1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Pro ...
- 计算机学院大学生程序设计竞赛(2015’12)Study Words
Study Words Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- 计算机学院大学生程序设计竞赛(2015’12)Polygon
Polygon Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
The Country List Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words
#include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...
- 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower
#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...
- 计算机学院大学生程序设计竞赛(2015’12) 1003 The collector’s puzzle
#include<cstdio> #include<algorithm> using namespace std; using namespace std; +; int a[ ...
- 计算机学院大学生程序设计竞赛(2015’12) 1004 Happy Value
#include<cstdio> #include<cstring> #include<cmath> #include<vector> #include ...
随机推荐
- 1.java.io包中定义了多个流类型来实现输入和输出功能,
1.java.io包中定义了多个流类型来实现输入和输出功能,可以从不同的角度对其进行分 类,按功能分为:(C),如果为读取的内容进行处理后再输出,需要使用下列哪种流?(G) A.输入流和输出流 B ...
- think in uml-关系
1.关联关系association 在一段时间内将多个类的实例连接在一起 某个对象在一段时间内一直"知道"另一个对象的存在 2.依赖关系dependency 一个对象的修改会导致另 ...
- PCI源码学习笔记
这个是PCI的关键结构体. static const struct file_operations proc_bus_pci_operations = { .owner = THIS_MODULE, ...
- JS-加载页面的时候自动选择刚才所选择option
<body class="no-skin" onload="option_auto(${pd.PACK_SORT})"> <select na ...
- php杂乱
// // if ( $_GET['action'] == 'search' ) {// $_clean = array();// $_clean['stype ...
- C: define many functions using predefine..
/* Defines COUNTER. There must be exactly one such definition at file scope * within a program. */ # ...
- Struts2值栈详解
1. 关于值栈: 1). helloWorld 时, ${productName} 读取 productName 值, 实际上该属性并不在 request 等域对象中, 而是从值栈中获取的. 2). ...
- html5利用websocket完成的推送功能
利用websocket和java完成的消息推送功能,服务器用的是tomcat7.0,一些东西是自己琢磨的,也不知道恰不恰当,不恰当处,还请各位见谅,并指出. 程序简单来说,就是客户A可以发送消息给客户 ...
- 1--OC -- HelloWorld
一.点击Xcode,选择“Create a new Xcode project” 二.左边选择“OS X Application”,右边选择“Command Line Tool”,Next 三.输 ...
- ThinkPHP3.2.3版本框架could not find driver错误
ThinkPHP3.2.3版本框架could not find driver错误 在更新ThinkPHP框架 3.2.3 时出现错误 解决方法如下: 修改php.ini文件 extension=php ...