计算机学院大学生程序设计竞赛(2015’12)01 Matrix
01 Matrix
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 564    Accepted Submission(s): 121
Given a "01" matrix with size by n*n (the matrix size is n*n and only contain "0" or "1" in each grid), please count the number of "1" matrix with size by k*k (the matrix size is k*k and only contain "1" in each grid).
Each test case begins with two numbers n and m (0<n, m<=1000), specifying the size of matrix and the query number.
Then n lines follow and each line contains n chars ("0" or "1").
Then m lines follow, each lines contains a number k (0<k<=n).
2
2 2
01
00
1
2
3 3
010
111
111
1
2
2
1
0
7
2
2
总是望着曾经的空间发呆,那些说好不分开的朋友不在了,转身,陌路。 熟悉的,安静了, 安静的,离开了, 离开的,陌生了, 陌生的,消失了, 消失的,陌路了。
#include <iostream>
#include<stdio.h>
#include <cstring>
using namespace std;
int a[1001][1001] ,b[1000];
char s[1001][1001];
int main()
{
int t,n,m;
cin>>t;
while(t--)
{
cin>>n>>m;
int ma=0;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i=0; i<n; i++)
scanf("%s",s[i]);
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
a[i+1][j+1]=s[i][j]-'0';
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
{
if(a[i][j]==1)
{
int mi=a[i-1][j-1];
if(mi>a[i-1][j])mi=a[i-1][j];
if(mi>a[i][j-1])mi=a[i][j-1];
mi++;
a[i][j]=mi;
b[mi]++;
ma=max(mi,ma);
}
}
for(int i=ma; i>1; i--)
{
b[i-1]+=b[i];
}
int x;
for(int i=0; i<m; i++)
{
cin>>x;
cout<<b[x]<<endl;
}
}
return 0;
}
@执念  "@☆但求“❤”安★
 下次我们做的一定会更好。。。。
为什么这次的题目是英文的。。。。QAQ...
计算机学院大学生程序设计竞赛(2015’12)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) 1006 01 Matrix
		
#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> ...
 - 计算机学院大学生程序设计竞赛(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[ ...
 
随机推荐
- 团伙(codevs 2597)
			
题目描述 Description 1920年的芝加哥,出现了一群强盗.如果两个强盗遇上了,那么他们要么是朋友,要么是敌人.而且有一点是肯定的,就是: 我朋友的朋友是我的朋友: 我敌人的敌人也是我的朋友 ...
 - excel打乱各行的顺序,实现无序随机排列
			
由于公司做活动,经常会发些激活码过来,为了让激活码能够充分使用,经常要打乱激活码的顺序,百度了下,看了下网上的介绍,还不错,挺实用,记录下来. 具体方法如下: 1.将文本里的内容复制到Excel里的任 ...
 - 标准C程序设计七---21
			
Linux应用 编程深入 语言编程 标准C程序设计七---经典C11程序设计 以下内容为阅读: <标准C程序设计>(第7版) 作者 ...
 - php——配合QQ邮箱发送邮件
			
最近做一个域名管理系统的项目,实现在域名还有三十天的时候系统发送邮件到QQ邮箱从而提醒续费: 这里运用到了phpmailer; 1:getAll函数: function getAll($con,$sq ...
 - HDU4850 构造一个长度为n的串,要求任意长度为4的子串不相同
			
n<=50W.(使用26个字母) 构造方法:26个,最多构造出26^4种不同的串,长度最长是26^4+3,大于是输出"impossble",用四维数组判重.每次向前构造一位( ...
 - android studio settings
			
安装 Android Studio下载地址 http://www.android-studio.org/ 1.配置JDK 2.安装 Android Studio (带SDK) 3.配置 一.Set ...
 - codevs——1690 开关灯
			
1690 开关灯 USACO 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Description YYX家门前的街上有N( ...
 - WIN7实现多用户远程桌面
			
版权声明:本文为博主原创文章,未经博主允许不得转载. 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://jonnyqin.blog. ...
 - 安装ftp服务器
			
Linux安装ftp组件 1 安装vsftpd组件 安装完后,有/etc/vsftpd/vsftpd.conf文件,是vsftp的配置文件. [root@bogon ~]# yum -y insta ...
 - fatal error C1189: #error : core.hpp header must be compiled as C++
			
两次opencv工程需要设置为C++编译:找了一半天的解决方法. I am building a C application that uses OpenCV. when compiling, I g ...