题目链接: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. coreseek 中文搜索和高亮

    配置文件 # # Minimal Sphinx configuration sample (clean, simple, functional) # source post { type = mysq ...

  2. easyUI中tree的简单使用

    一.在JS中的代码 $('#tt').tree({ url: baseCtx + 'lib/easyui-1.4/demo/tree/tree_data1.json',//tree数据的来源,json ...

  3. 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【九】——API变了,客户端怎么办?

    系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 一旦我们将API发布之后,消费者就会开始使用并和其他的一些数据混在一起.然而,当新的需求出现 ...

  4. robots.txt的介绍和写作

    目前很多网站管理者似乎对robots.txt并没有引起多大重视,甚至不知道这么一个文件的作用.本来应该保密的信息被爬虫抓取了,公布在公网上,本应该发布到公网的信息却迟迟不被搜索引擎收录.所以下面这篇文 ...

  5. Google

    1. Google Play: Google Play是谷歌官方的的应用市场, Google Play 服务通常会在 Android 装置上自动更新. http://baike.baidu.com/l ...

  6. Apache源码包安装和子配置文件介绍--update.2014-12-5

    安装apache: 官网:http://httpd.apache.org/download.cgi#apache24 1.wget http://mirror.bit.edu.cn/apache//h ...

  7. Autofac.Integration.Mvc.Owin分析

    using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Secur ...

  8. fis总结

    1.fis捕获组 $1.$2.$3……是正则表达式替换中对捕获组的引用 $0或$&是对整个匹配字符串的引用 2.fis命令 fis3 release -d ../output prod -wL ...

  9. Linux jdk1.7安装与 jdk1.6卸载

    昨天安装zookeeper时需要java环境,也就是安装jdk    安装完jdk1.7后,配置好环境变量, vim ~/.bashrc       JAVA_HOME=安装路径 export PAT ...

  10. firefox的plugin-container.exe进程如何关闭?

    为什么要关闭container进程? 查看firefox所消耗的资源: ff本身: cpu一般是0-10%, 内存一般是400MB左右 plugin-container: cpu所占的比例很高, 可达 ...