POJ 1856(海战)
来源:互联网 发布:linux c sleep 头文件 编辑:程序博客网 时间:2024/04/30 01:37
搜索 此题数据小,不需要状压
Program P1856;var n,m,i,j,ans:longint; c:char; f:array[0..1010,0..1010] of boolean;function find(x,y:longint):boolean;var i,j,k,l:longint;begin i:=x;j:=y; while f[x,j] do inc(j); dec(j); while f[i,y] do inc(i); dec(i); for k:=x to i do for l:=y to j do begin if not(f[k,l]) then exit(false); f[k,l]:=false; end; for k:=x-1 to i+1 do if f[k,j+1] or f[k,y-1] then exit(false); for l:=y to j do if f[i+1,l] or f[x-1,l] then exit(false); exit(true);end;function main:boolean;var i,j:longint;begin ans:=0; for i:=1 to n do for j:=1 to m do if f[i,j] then begin if not(find(i,j)) then exit(false) else inc(ans); end; exit(true);end;begin while not seekeof do begin fillchar(f,sizeof(f),false); readln(n,m); if (n+m=0) then break; for i:=1 to n do begin for j:=1 to m do begin read(c); if c='#' then f[i,j]:=true; end; readln; end; if main then writeln('There are ',ans,' ships.') else writeln('Bad placement.'); end;end.
- POJ 1856(海战)
- 海战
- Codevs 1536 海战 (DFS || BFS)+判断
- Sea Battle<海战>(思路题)
- 洛谷P1331 海战(老是打成寒战GG)
- 海战游戏
- codevs1536 海战
- [vijosP1076]海战
- 【u006】海战
- 《疯狂海战》策划案
- 蓝海战略
- 蓝海战略
- 蓝海战略?
- 蓝海战略
- 蓝海战略
- 《蓝海战略》读书笔记
- 【其他】wikioi 1536 海战
- 蓝海战略
- 尚管学习第三天笔记
- Ubuntu Google输入法(基于ibus)安装
- Android 各版本历史主要变动(Version1.5-->4.0)全面整理
- Mini2440 触摸屏驱动分析
- 通过ADB命令刷入boot.img和recovery.img的方法
- POJ 1856(海战)
- Linux高级路由---策略路由/捆绑/网桥
- jquery UI draggable学习
- vbs操作excel全集
- Android利用RotateAnimation实现旋转变化动画
- android下的文件上传
- android原生widget 电量控制(PowerSave)设计浅析
- Windows7各版本功能区别(含图)
- poj 3468 很水的线段树lazy操作,为了理解hdu 3954 的 lazy做的。