今天看了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的更多相关文章

  1. [2012山东省第三届ACM大学生程序设计竞赛]——Mine Number

    Mine Number 题目:http://acm.sdut.edu.cn/sdutoj/problem.php? action=showproblem&problemid=2410 Time ...

  2. Mine Number(搜索,暴力) ACM省赛第三届 G

    Mine Number Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Every one once played the gam ...

  3. 【python游戏编程之旅】第五篇---嗷大喵爱吃鱼小游戏开发实例

    本系列博客介绍以python+pygame库进行小游戏的开发.有写的不对之处还望各位海涵. 我们一同在前几期的博客中已经学到了很多pygame的基本知识了,现在该做个小游戏实战一下了. 前几期博客链接 ...

  4. 山东省第三届ACM省赛

    Solved ID PID Title Accepted Submit   A 2407 Impasse (+) 0 0   B 2415 Chess 0 0   C 2414 An interest ...

  5. 8659 Mine Sweeping

    时间限制:500MS  内存限制:65535K提交次数:37 通过次数:15 题型: 编程题   语言: G++;GCC Description The opening ceremony of the ...

  6. POJ 3340 &amp; HDU 2410 Barbara Bennett&#39;s Wild Numbers(数学)

    题目链接: PKU:http://poj.org/problem?id=3340 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2410 Descript ...

  7. 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 ...

  8. How To Mine Bitcoins 比特币挖矿

    linux 下查看 gpu 的信息: sudo lshw -C display windows下查看cuda信息:In directory C:\Program Files\NVIDIA Corpor ...

  9. HDU 4678 Mine (2013多校8 1003题 博弈)

    Mine Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

随机推荐

  1. 项目构建工具Gradle的使用入门(参考,只表明地址)

    Gradle入门介绍:简介 http://blog.jobbole.com/71999/ Gradle入门介绍:第一个Java项目 http://blog.jobbole.com/72558/ Gra ...

  2. php头像上传并裁剪支持3个尺寸

    源码下载

  3. struts中拦截器的开发

    1.开发Interceptor类 用户自定义的拦截器一般需要继承AbstractInterceptor类,重写intercept方法 public class UserInterceptor exte ...

  4. 一台服务器搭载两个tomcat项目

    之前下载的mysql  在官网是有 历史库的 如果现在一台机器上已经部署了一个tomcat服务,无论这个tomcat是否已经注册为服务了,或者没有注册windows服务,或者注册了,都没关系.都可以采 ...

  5. Problem A 栈

    Description   You are given a string consisting of parentheses () and []. A string of this type is s ...

  6. MSP430x1_4_6x之问题总结

    01:MSP430端口上电复位的初始值是不确定的:所以使用是都要初始化:比如加下面的语句或者加你使用的端口就行了:  /*下面六行程序关闭所有的IO口*/    P1DIR = 0XFF;P1OUT ...

  7. Java---NullPoint经验解析

    tv_yue = (TextView) findViewById(R.id.tv_yue); if(!Constant.cf_balance.isEmpty()){ tv_yue.setText(Co ...

  8. Ubuntu 14.10 下MySQL无法远程连接问题

    安装好MySQL之后,如果需要远程连接,那么需要做一些配置,否则会出现一些类似的错误,如 mysql root用户ERROR (): mysql 远程登录 ERROR () mysql 远程登录200 ...

  9. (转) mysql的连接,创建账号,修改密码

    原文:http://blog.chinaunix.net/uid-20749043-id-1878306.html  mysql的连接,创建账号,修改密码 2008-10-13 15:31:29 分类 ...

  10. Be Careful With BuildConfig.DEBUG

    Be Careful With BuildConfig.DEBUG http://www.digipom.com/be-careful-with-buildconfig-debug/