ZOJ Problem Set - 2922 Bombs
来源:互联网 发布:湖北中科网络欠款 编辑:程序博客网 时间:2024/04/26 09:17
一道简单题,注意不要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 - 2922 Bombs
- ZOJ 2922 Bombs(记忆化搜索)
- ZOJ Problem Set - 2060
- ZOJ Problem Set - 2972
- ZOJ Problem Set - 1037
- ZOJ Problem Set - 1048
- ZOJ Problem Set - 1049
- ZOJ Problem Set - 1051
- ZOJ Problem Set - 1067
- ZOJ Problem Set - 1115
- ZOJ Problem Set - 1151
- ZOJ Problem Set - 1205
- ZOJ Problem Set - 1025
- ZOJ Problem Set - 1029
- ZOJ Problem Set - 1076
- ZOJ Problem Set - 1117
- ZOJ Problem Set - 1041
- ZOJ Problem Set - 1004
- umask-文件权限的补码
- Java - 《Thinking in Java 第4版》
- Maya&Python&Nuke的几点笔记
- 乔布斯鲜为人知的私生活:低调、曾经多情
- Android开发点滴
- ZOJ Problem Set - 2922 Bombs
- 编程技术面试的五大要点
- 《巴伦周刊》:乔布斯的耐心成就苹果
- 如果乔布斯出生在中国...
- 后乔布斯时代亚洲PC品牌仍难超越苹果
- 在Flex中的LineChart线条上显示Label标识
- 面部识别技术发展 新的隐私问题出现
- GPU上大规模粒子系统的Dx9实现细节总结
- Linux中对虚拟机的远程访问