ZOJ Problem Set - 2922 Bombs
2011-10-08 22:22
211 查看
一道简单题,注意不要SE,就是数组访问越界。
从后面一直搜索下来,按纵列。
两个函数就可以搞定!
水了!
从后面一直搜索下来,按纵列。
两个函数就可以搞定!
水了!
#include <iostream> using namespace std; int map[1001][1001],m[1001][1001]; void setx(int x,int y); void sety(int x,int y) { int i; for(i = x;i >= 0;i --) { if(m[i][y] == 0) { m[i][y] = 1; setx(i,y); } } } void setx(int x,int y) { int i; for(i = y;i >= y-map[x][y];i --) { if(i>=0&&m[x][i] == 0) { m[x][i] = 1; setx(x,i); sety(x,i); } } } int main() { int i,j,cot,ma,n; while(cin>>n>>ma) { cot = 0; for(i = 0;i < n;i ++) for(j = 0;j < ma;j ++) { cin>>map[i][j]; if(map[i][j] == 0) m[i][j] = 1; else m[i][j] = 0; } for(i = ma-1;i >=0;i --) for(j = n-1;j >=0;j --) { if(m[j][i]==0) { cot ++; setx(j,i); sety(j,i); } } cout<<cot<<endl; } return 0; }
相关文章推荐
- ZOJ Problem Set - 1331 Perfect Cubes 判断一个double是否为整数
- ZOJ Problem Set - 1078(十进制对任意进制转换)
- ZOJ Problem Set – 1056 The Worm Turns
- ZOJ Problem Set - 1350 The Drunk Jailer ac代码 memset
- ZOJ Problem Set - 2744 Palindromes(字符串二分处理的好题)
- ZOJ Problem Set - 2876 Phone List
- ZOJ Problem Set - 2772 Quick Change
- ZOJ Problem Set - 2482||IP Address
- ZOJ Problem Set - 1392 The Hardest Problem Ever
- ZOJ Problem Set - 1003
- ZOJ Problem Set - 1007
- ZOJ Problem Set - 1711 解题报告
- ZOJ Problem Set - 1423 (Your)((Term)((Project)))
- ZOJ Problem Set - 1243 URLs
- ZOJ Problem Set - 3429 Cube Simulation
- ZOJ Problem Set - 3946 (限制的最短路)
- ZOJ Problem Set - 3405 Counting Factor Trees
- ZOJ Problem Set - 1007Numerical Summation of a Series
- ZOJ Problem Set - 1004
- ZOJ Problem Set -1259 Rails