HNU 12906 Battleship
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12906
解题报告:题目意思看了很久都没懂,就是一个10*10的方格,然后上面要放一些船,船的规格分别是1艘占4个格子的船,2艘占3个格子的,3艘占2 个格子的,4艘占一个格子的。然后输入是一个10*10的矩阵,数字都是1-100的数,数字表示将在哪个时刻会打到这个位置,当一艘船的每一个格子都被打中之后,这艘船就会下沉,要求两艘船之间不能相邻,然后让你求最复杂的船的排列方法,就是在这里,到底什么是最复杂的排列方法,真吭,原来就是要让你求这个矩阵上面要在最后才没有船的排列方法,这不就是只要在100那个位置一定要放船不就行了。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std; int map[][];
char ans[][],temp[][]; int main()
{
// freopen("in.txt","r",stdin);
for(int i = ;i <= ;++i)
for(int j = ;j <= ;++j)
{
scanf("%d",&map[i][j]);
ans[i][j] = temp[i][j] = '.';
}
ans[][] = ans[][] = ans[][] = '#';
ans[][] = ans[][] = '#';
ans[][] = ans[][] = '#';
ans[][] = ans[][] = '#';
ans[][] = ans[][] = ans[][] = '#';
ans[][] = ans[][] = ans[][] = '#';
ans[][] = ans[][] = ans[][] = ans[][] = '#';
int x,y;
for(int i = ;i <= ;++i)
for(int j = ;j <= ;++j)
if(map[i][j] == )
{
x = i,y = j;
temp[i][j] = '#';
break;
}
int f = ;
for(int i = (x&)? :;i <= ;i+=)
if(abs(i-x) > )
{
for(int j = ;j <= ;++j)
temp[i][j] = ans[f][j];
f++;
if(f > ) break;
}
for(int i = ;i <= ;++i)
{
temp[i][] = NULL;
puts(temp[i]+);
}
return ;
}
HNU 12906 Battleship的更多相关文章
- HNU 12888 Encryption(map容器)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12890&courseid=274 解题报告:输入一个有 ...
- HNU 12886 Cracking the Safe(暴力枚举)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12886&courseid=274 解题报告:输入4个数 ...
- HNU 12885 Bad Signal(模拟)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12885&courseid=274 解题报告:一共有n个 ...
- HNU 12868 Island (简单题)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12868&courseid=272 解题报告:输入n*m ...
- HNU 12869 Sequence(循环节)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12869 解题报告:看到n的范围这么大,一看就是找规律,把前30 ...
- Greedy --- HNU 13320 Please, go first
Please, go first Problem's Link: http://acm.hnu.cn/online/?action=problem&type=show&id=13320 ...
- HNU 13308 Help cupid
Help cupid Problem's Link: http://acm.hnu.cn/online/?action=problem&type=show&id=13308&c ...
- HNU 12847 Dwarf Tower(最短路+队列优化)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12847 解题报告:有n样物品,编号从1到n第i样物品可以通过金 ...
- HNU 12845 Ballot Analyzing Device
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12845&courseid=270 解题报告:有m个认给 ...
随机推荐
- springMVC的注解详解
springmvc常用注解标签详解 1.@Controller 在SpringMVC 中,控制器Controller 负责处理由DispatcherServlet 分发的请求,它把用户请求的数据经过业 ...
- gettextize与glib-gettextize的使用
gettextize在各种场合都可以使用,用于支持多语言开发 glib-gettextize运行后,会修改po/Makefile.in.in文件,导致后续都必须运行glib-gettextize ge ...
- 天行API服务器地址申请
http://www.tianapi.com/ http://www.huceo.com/post/383.html
- 查看apt-get安装软件的版本
apt-cache search name 查询 apt-get install name 安装 dpkg dpkg dpkg-checkbuilddeps dpkg-genchanges dpkg- ...
- 【codeblocks配置】C对Mysql数据的查询
codeblocks 编写C文件连接mysql数据库 codeblocks 设置.1.设置lib库文件: Settings->Compiler settings->Linker setti ...
- 入门:JavaWeb Cookie
总结: JavaWeb 利用Cookie 存储在本地用户名和密码,设置Cookie的生存时间. 两个页面,一个登陆页面,一个登陆后的页面,在登陆页面选择是否保存Cookie(保存Cookie,下次自动 ...
- Intent启动一个新的页面
一,Intent(目的) 的分类 显式 Intent 构造函数重载之一: Intent intent = new Intent(FirstActivity.this,SecondActivity.cl ...
- Auto generating Entity classes with xsd.exe for XML Serialization and De-Serialization
More info here: http://blogs.msdn.com/b/yojoshi/archive/2011/05/14/xml-serialization-and-deserializa ...
- Think in Java(Java编程思想)-第2章 一切都是对象
1. String s = "asdf"//创建一个String引用,并初始化. String s = new String("asdf")//创建一个新对象, ...
- html、css杂记
1:浮动 <div style="float: left"> 2:清除浮动,把父div撑起来 <div style="clear:both"& ...