#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的更多相关文章

  1. hdu 计算机学院大学生程序设计竞赛(2015’11)

    搬砖 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...

  2. 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排

    1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  3. 计算机学院大学生程序设计竞赛(2015’12)Study Words

    Study Words Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  4. 计算机学院大学生程序设计竞赛(2015’12)Polygon

    Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  5. 计算机学院大学生程序设计竞赛(2015’12)The Country List

    The Country List Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words

    #include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...

  7. 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower

    #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...

  8. 计算机学院大学生程序设计竞赛(2015’12) 1003 The collector’s puzzle

    #include<cstdio> #include<algorithm> using namespace std; using namespace std; +; int a[ ...

  9. 计算机学院大学生程序设计竞赛(2015’12) 1004 Happy Value

    #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include ...

随机推荐

  1. table新增空白行到首行

    var str=""; str+="<tr bordercolor='#DEDEDE' bgcolor='#ffffff'>"; str+=&quo ...

  2. 删除sql计划 调用的目标发生了异常。 (mscorlib) 其他信息: 用户 'sa' 登录失败。

    在删除以前创建的sql的计划任务时,弹出如题错误提示,发现错误原因在于,sa密码更改过,导致在删除时因为sa的密码和当前的密码不正确出现此错误. 解决办法: 1.在计划任务的编辑窗口,找到管理连接 2 ...

  3. mysql开启/关闭 update delete 安全模式

    在使用mysql执行update的时候,如果不是用主键当where语句,会报如下错误,使用主键用于where语句中正常. 异常内容:Error Code: 1175. You are using sa ...

  4. 以excel方式输出数据

    主类Test: public class D201 {//get set 方法略去 private String d201_01; private String d201_02; private St ...

  5. 移植Iperf到android 用来学习linux移植到安卓的例子

    Iperf移植记录 1.生成arm编译需要的头文件config.h ./configure --host=arm如果需要make clean make distclean2.增加Android.mk文 ...

  6. Coupons and Discounts

    Coupons and Discounts time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. cfedu/A/求和

    题目连接 思路: 用数组直接标记2^n,n属于(0~~31);用LL或者INT都可以,不会爆.但是ans要用LL. #include <set> #include <map> ...

  8. java断点

    第一步: 用firefox运行程序,当点击保存,提示保存失败后,启动firebug 通过请求找到addNew.ezt出现错误,在eztnews.xml里通过ctrl+F查找找到请求执行的类和方法 找到 ...

  9. Android中布局文件中使用onClick属性

    安卓开发中,布局文件中的控件有一个属性,是onClick,例如:           <Button             android:id="@+id/button1" ...

  10. HDU - 1083 Courses /POJ - 1469

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1083 http://poj.org/problem?id=1469 题意:给你P个课程,并且给出每个课 ...