计算机学院大学生程序设计竞赛(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[ ...
随机推荐
- C Looooops(poj 2115)
大致题意: 对于C的for(i=A ; i!=B ;i +=C)循环语句,问在k位存储系统中循环几次才会结束. 若在有限次内结束,则输出循环次数. 否则输出死循环. 解题思路: 题意不难理解,只是利用 ...
- android开发里跳过的坑——TimePickerDialog onTimeSet不回调
在android6.0.1上测试发现TimePickerDialog的onTimeSet和DatePickerDialog的onDateSet不回调,查看SDK源码发现,TimePickerDialo ...
- javascript实现数据结构----栈
//栈是一种遵从后进先出原则的有序集合. //新添加的或待删除的元素都保存在栈的末尾,称作栈顶,另一端就叫栈底 //在栈里,新元素都靠近栈顶,旧元素都叫做栈底 function Stack(){ va ...
- MySQL导出数据库、数据库表结构、存储过程及函数【用】
一.导出数据库 我的mysql安装目录是D:\Program Files\MySQL\MySQL Server 5.5\bin\,导出文件预计放在D:\sql\ 在mysql的安装目录执行命令: my ...
- Docker如何部署Python项目
Docker 部署Python项目 作者:白宁超 2019年5月24日09:09:00 导读: 软件开发最大的麻烦事之一就是环境配置,操作系统设置,各种库和组件的安装.只有它们都正确,软件才能运行.如 ...
- 十步叫你如何无损修复硬盘锁(mbr病毒)
经常看见有人被锁硬盘 开机以后出现一行红字 FUCK YOU POJIEZHE 等等云云的 这个问题主要还是病毒对Mbr分区的修改造成的 下面我教给大家一个无损数据 无损硬盘 无需重装系统 ...
- VisualSVN Server 导入已存在的库
http://blog.csdn.net/lidatgb/article/details/7984220 早些时候建立过一个SVN Server的库,后来觉得库的名字太长了,随意换了一 ...
- [Unit Testing] Fundamentals of Testing in Javascript
In this lesson, we’ll get the most fundamental understanding of what an automated test is in JavaScr ...
- Java 实现 淘宝秒杀 聚划算 自己主动提醒 源代码
说明 本实例可以监控聚划算的抢购button,在聚划算整点聚的时间到达时自己主动弹开页面(URL自定义). 能够自己定义监控持续分钟数,同一时候还能够通过多线程加快刷新速度. 源代码 package ...
- 删除DataGridView选中行并更新数据库
前面写过一篇文章是DataGridView控件显示数据的,DataGridView在与数据库打交道时会常常出现,也非常有用.通过DataGridView对数据库进行更改和查询都比較方便. 这里我们须要 ...