题目链接: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的更多相关文章

  1. HNU 12888 Encryption(map容器)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12890&courseid=274 解题报告:输入一个有 ...

  2. HNU 12886 Cracking the Safe(暴力枚举)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12886&courseid=274 解题报告:输入4个数 ...

  3. HNU 12885 Bad Signal(模拟)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12885&courseid=274 解题报告:一共有n个 ...

  4. HNU 12868 Island (简单题)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12868&courseid=272 解题报告:输入n*m ...

  5. HNU 12869 Sequence(循环节)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12869 解题报告:看到n的范围这么大,一看就是找规律,把前30 ...

  6. Greedy --- HNU 13320 Please, go first

    Please, go first Problem's Link: http://acm.hnu.cn/online/?action=problem&type=show&id=13320 ...

  7. HNU 13308 Help cupid

    Help cupid Problem's Link: http://acm.hnu.cn/online/?action=problem&type=show&id=13308&c ...

  8. HNU 12847 Dwarf Tower(最短路+队列优化)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12847 解题报告:有n样物品,编号从1到n第i样物品可以通过金 ...

  9. HNU 12845 Ballot Analyzing Device

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12845&courseid=270 解题报告:有m个认给 ...

随机推荐

  1. python不同模式打开文件的完全列表

    模式 描述 r 以只读方式打开文件.文件的指针将会放在文件的开头.这是默认模式. rb 以二进制格式打开一个文件用于只读.文件指针将会放在文件的开头.这是默认模式. r+ 打开一个文件用于读写.文件指 ...

  2. 理解与应用css中的display属性

    理解与应用css中的display属性 display属性是我们在前端开发中常常使用的一个属性,其中,最常见的有: none block inline inline-block inherit 下面, ...

  3. Django 部署 uwsgi + nginx + supervisor

    Django 部署 uwsgi + nginx + supervisor https://hacpai.com/article/1460607620615?p=1&m=0 zonghua • ...

  4. EasyUI——常见用法总结

    1. 使用 data-options 来初始化属性. data-options是jQuery Easyui 最近两个版本才加上的一个特殊属性.通过这个属性,我们可以对easyui组件的实例化可以完全写 ...

  5. mysql查看表使用的数据库引擎

    看某个使用的引擎,在显示结果里参数engine后面的就表示该表当前用的存储引擎: mysql> show create table 表名; 看mysql支持哪些存储引擎: mysql> s ...

  6. Cloudservice程序设置Idle timeout

    部署的云服务程序,默认的idle timeout是4分钟,意味着如果你通过一个workerrole发布了wcf服务,客户端第一次调用服务方法后,再过4分钟尝试去重新调用服务,会报错,具体测试如下: 1 ...

  7. ecshop修改产品详情 折扣倒计时时间

    文件:lefttime.js  位置:/js/lefttime.js 要求:去掉倒计时时间的 “天”数 原代码 ) { Temp = dateLeft + _day + hourZero + hour ...

  8. yourphp点击刷新验证码

    加入css <script type="text/javascript" src="./Public/Js/my.js"></script&g ...

  9. bootloader

    1) C# 为了给设备升级固件,在前同事的基础上改了下,在.NET Framework下写的. 2)Tera Term + ttl 上面.NET平台的运行文件虽然小巧,但是依赖.NET Framewo ...

  10. IIS Express 虚拟目录

    1.打开C:\Users\<用户名>\Documents\IISExpress\config\applicationhost.config 2.编辑site节如下(行4) [html] v ...