sdust 2410 Mine Number
今天看了3个这种题了 枚举第一行即可
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<string>
#define maxn
#define INF
using namespace std;
typedef long long LL;
int n,m,flag; int num1[][],num2[][];
int get_sum(int i,int j)
{
int tem=num2[i][j];
if(i>)
tem+=num2[i-][j];
if(j<m-)
tem+=num2[i][j+];
if(j>)
tem+=num2[i][j-];
return tem;
}
int check(int x)
{
int ans=num2[][x];
if (x)
ans+=num2[][x-];
if (x<m-)
ans+=num2[][x+];
if (ans==num1[][x] || ans+==num1[][x])
return true;
return false;
}
int puan(int s)
{
for(int j=;j<m;j++)
{
if((s&(<<j)))
num2[][j]=;
else
num2[][j]=;
}
if(n==)
{
for(int i=;i<m;i++)
if(get_sum(,i)!=num1[][i])
return ;
return ;
}
for(int i=;i<m;i++)
{
if(!check(i))
return ;
}
for(int i=;i<n;i++)
for(int j=;j<m;j++)
{
if(get_sum(i-,j)==num1[i-][j])
num2[i][j]=;
else if(get_sum(i-,j)+==num1[i-][j])
num2[i][j]=;
else
return ; }
for(int i=;i<m;i++)
if(get_sum(n-,i)!=num1[n-][i])
return ;
return ;
}
int main()
{ char str[];
int t;
while(scanf("%d",&t)!=EOF)
{
for(int ii=; ii<=t; ii++)
{
scanf("%d%d",&n,&m);
for(int i=; i<n; i++)
{
scanf("%s",str);
for(int j=; j<m; j++)
num1[i][j]=str[j]-'';
} for(int i=; i<(<<m); i++)
{
if(puan(i))
break;
}
printf("Case %d:\n",ii);
for(int i=; i<n; i++)
{
for(int j=; j<m; j++)
{
if(num2[i][j])
printf("*");
else
printf(".");
}
printf("\n");
}
}
} return ;
}
sdust 2410 Mine Number的更多相关文章
- [2012山东省第三届ACM大学生程序设计竞赛]——Mine Number
		
Mine Number 题目:http://acm.sdut.edu.cn/sdutoj/problem.php? action=showproblem&problemid=2410 Time ...
 - Mine Number(搜索,暴力) ACM省赛第三届 G
		
Mine Number Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Every one once played the gam ...
 - 【python游戏编程之旅】第五篇---嗷大喵爱吃鱼小游戏开发实例
		
本系列博客介绍以python+pygame库进行小游戏的开发.有写的不对之处还望各位海涵. 我们一同在前几期的博客中已经学到了很多pygame的基本知识了,现在该做个小游戏实战一下了. 前几期博客链接 ...
 - 山东省第三届ACM省赛
		
Solved ID PID Title Accepted Submit A 2407 Impasse (+) 0 0 B 2415 Chess 0 0 C 2414 An interest ...
 - 8659 Mine Sweeping
		
时间限制:500MS 内存限制:65535K提交次数:37 通过次数:15 题型: 编程题 语言: G++;GCC Description The opening ceremony of the ...
 - POJ 3340 & HDU 2410 Barbara Bennett's Wild Numbers(数学)
		
题目链接: PKU:http://poj.org/problem?id=3340 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2410 Descript ...
 - hdu4678   Mine   2013 Multi-University Training Contest 8   博弈题
		
Mine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submi ...
 - How To Mine Bitcoins 比特币挖矿
		
linux 下查看 gpu 的信息: sudo lshw -C display windows下查看cuda信息:In directory C:\Program Files\NVIDIA Corpor ...
 - HDU 4678 Mine (2013多校8 1003题  博弈)
		
Mine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
 
随机推荐
- Linearizability and Sequential Consistency
			
Linearizability and Sequential Consistency a) A sequentially consistent data store. b) A data store ...
 - 键盘控制select选项上下
			
$('#k').live('keydown',function(event){ if (event.keyCode==38){ /*$(this).addClass("active" ...
 - POJ 2762 tarjan缩点+并查集+度数
			
Going from u to v or from v to u? Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 15494 ...
 - 设置groupBox背景透明
			
步骤:属性-BackColor-WEB面板-Transparent
 - checkbox全选功能
			
$("#cb_classType_all").change(function () { if ($(this).is(":checked")) { $(&quo ...
 - Linux 常用
			
1,解决ssh登录慢的问题记录 vim /etc/ssh/ssh_config # GSSAPIAuthentication no 把下面这一行的注释去掉 2,Linux查看当前是什么系统 ...
 - VS2010中添加lib库引用
			
VS2010中添加lib库引用: 1 菜单 项目---> 属性--->配置属性-->链接器---->输入---附加依赖项, 加入库名,如: my_API.lib; 或是在c ...
 - CCNA 4.14 TP Correction
			
All people seem to need data processing ( Application presentation session transport network data li ...
 - vector用法总结(转载)
			
一.vector的基本概念 vector是同一种类型的对象的集合,每个对象都有一个对应的整数索引值.和string对象一样,标准库负责管理存储元素的相关内存.我们把vector称为容器,是因为它可以包 ...
 - a Makefile
			
obj-m += showpid.o obj-m += ps.o all: make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) mo ...