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个认给 ...
随机推荐
- spring+hibernate ---laobai
biz包: package com.etc.biz; import java.util.List; import org.springframework.orm.hibernate3.support. ...
- Objective-C 中的类和对象
http://blog.ibireme.com/2013/11/25/objc-object/ Objective-C的runtime是开源的,源码可以在苹果官网下载到:objc4. 在objc4-5 ...
- 【原】js离开页面执行函数 onbeforeunload与onunload事件
在最近的项目中,需要做到一个时间,就是用户离开页面的时候,我需要缓存页面其中一部分的内容,但是我不需要用户刷新的时候也缓存,我只希望在我用户离开的时候 执行这个函数.百度之,有onbeforeunlo ...
- 数组Arrays
1.toString 方法 Arrays的toString方法可以方便的输出一个数组的字符串形式,方便查看,它有九个重载的方法,包括八种基本类型数组和一个对象类型数组,这里列举两个: public s ...
- matlab连接sql数据库
最近项目还涉及到matlab连接数据库,下面我就记录如何进行配置使得matlab能够连接sql数据库.由于最近工程做的多一些,所以分享的都在工程配置上,当初为了这些配置可是反复卸载与重装,算法其实也有 ...
- Bootstrap基本类和组件学习二
一.联系方式:(自带鼠标的移动动画) 1.头文件CSS <link rel="shortcut icon" href="favicon.ico"> ...
- Flask-WTF form doesn't have attribute 'validate_on_submit'问题
今天在学习WTF表单的时候遇到了这个问题,在stackoverflow上搜索查到了解决方案 from flask.ext.wtf import Form from wtforms import Tex ...
- Zookeeper集群的安装和使用
Apache Zookeeper 由 Apache Hadoop 的 Zookeeper 子项目发展而来,现已经成为 Apache 的顶级项目,它是一个开放源码的分布式应用程序协调服务,是Google ...
- strcpy函数的实现
strcpy函数的实现 大家一般认为名不见经传strcpy函数实现不是很难,流行的strcpy函数写法是: char *my_strcpy(char *dst,const char *src) { a ...
- HTML+JS+DOM【选项卡自动切换】
最终效果图(鼠标无操作会自动切换选项卡): <!DOCTYPE html> <html> <head> <meta charset="gb2312& ...