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个认给 ...
随机推荐
- Apache Nutch v2.3 发布,Java实现的网络爬虫
http://www.oschina.net/news/59287/apache-nutch-2-3 Apache Nutch v2.3已经发布了,建议所有使用2.X系列的用户和开发人员升级到这个版本 ...
- 9.19 JS数组
数组:相同类型数据的集合强类型语言:1数组里面只能存放相同数据类型的数据 2定义数组的时候需要制定一个长度(可以存放的元素数量) 3内存空间连续集合:1.可以存放任意类型的数据 ...
- MySQL的mysqldump工具的基本用法
导出要用到MySQL的mysqldump工具,基本用法是: shell> mysqldump [OPTIONS] database [tables] 如果你不给定任何表,整个数据库将 ...
- /MT、/MD编译选项,以及可能引起在不同堆中申请、释放内存的问题
一.MD(d).MT(d)编译选项的区别 1.编译选项的位置 以VS2005为例,这样子打开: 1) 打开项目的Property Pages对话框 2) 点击左侧C/C ...
- MySQL学习笔记——多表连接和子查询
多表连接查询 # 返回的是两张表的乘积 SELECT * FROM tb_emp,tb_dept SELECT COUNT(*) FROM tb_emp,tb_dept # 标准写法,每个数据库都能这 ...
- centos忘记开机密码
系统:centos6.6,忘记开机密码,进入单用户模式进行重置,以下为操作过程. 1. reset(重启)Linux系统,在出现如下图的界面时,请点Enter键,确保一定要快,只存在几秒.. 2.点击 ...
- NestIn VS插件 visual studio 中将同类CS文件放在一起显示
https://visualstudiogallery.msdn.microsoft.com/9d6ef0ce-2bef-4a82-9a84-7718caa5bb45 Nest files in So ...
- 【Delphi】GIF 动画建立
var Gif:TGifImage; begin //Setting the delay for each frame TGIFGraphicControlExtension.; TGIFGraphi ...
- JavaScriptSerializer中日期序列化问题
js请求的json数据返回前台的DateTime 类型被替换成了:\/Date(1404098342309)\/. 这个1404098342309数值,是1970年1月1日(DateTime的最小值) ...
- IOS开发中@2x图片等适应不同分辨率手机
开发中,例如: nanshanImage.image=[UIImage imageNamed:@'index_pic.png']; 在项目中还保存中index_pic@2x.png的图片,此图为了只适 ...