七 Mega Man's Mission

Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu

 #include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; long long dp[];
int enemy[],weapons[]; int main()
{
int T,ca=;
int n,mega;
char s[];
int i,j,k;
scanf("%d",&T);
while(T--)
{
mega=;
memset(dp,,sizeof(dp));
memset(enemy,,sizeof(enemy));
memset(weapons,,sizeof(weapons)); scanf("%d",&n);
scanf("%s",s);
for(i=;i<n;i++)
{
if(s[i]=='')
{
mega=mega | ( << i);
}
}
for(i=;i<n;i++)
{
scanf("%s",s);
for(j=;j<n;j++)
{
if(s[j]=='')
{
enemy[i]=enemy[i] | ( << j);
}
}
}
for(i=;i<( << n);i++)
{
weapons[i]=mega;
for(j=;j<n;j++)
{
if(i & <<j)
{
weapons[i]=weapons[i] | enemy[j];
}
}
} dp[]=;
for(i=;i<(<<n);i++)
{
if(dp[i] == ) continue;
for(j=;j<n;j++)
{
if((weapons[i] & (<<j))!= && (i & (<<j))==)
dp[i | (<<j)]=dp[i | (<<j)]+dp[i];
}
} printf("Case %d: %lld\n",++ca,dp[(<<n)-]);
}
return ;
}

UVA 11795 七 Mega Man's Mission的更多相关文章

  1. 状压DP UVA 11795 Mega Man's Mission

    题目传送门 /* 题意:洛克人有武器可以消灭机器人,还可以从被摧毁的机器人手里得到武器,问消灭全部机器人的顺序总数 状态压缩DP:看到数据只有16,就应该想到状压(并没有).因为是照解题报告写的,代码 ...

  2. UVA - 11795 Mega Man's Mission

    Mega Man is off to save the world again. His objective is to kill the Robots created by Dr. Wily who ...

  3. UVa 11795 Mega Man's Mission (状压DP)

    题意:你最初只有一个武器,你需要按照一定的顺序消灭n个机器人(n<=16).每消灭一个机器人将会得到他的武器. 每个武器只能杀死特定的机器人.问可以消灭所有机器人的顺序方案总数. 析:dp[s] ...

  4. UVa 11795 状压DP Mega Man's Mission

    kill[S]表示消灭机器人的集合为S,剩下的所能杀死的机器人集合. 设d(S)表示杀死机器人集合为S的方法数,答案为d((1<<n) - 1). d(S)可以由d(S')转移过来,其中S ...

  5. UVA Mega Man's Mission(状压dp)

    把消灭了那些机器人作为状态S,预处理出状态S下可以消灭的机器人,转移统计方案.方案数最多16!,要用64bit保存方案. #include<bits/stdc++.h> using nam ...

  6. UVA 11795

    B Mega Man’s Missions Input Standard Input Output Standard Output Mega Man is off to save the world ...

  7. UVA11795 Mega Man's Mission

    状压dp #include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> ...

  8. 【状压DP】【UVA11795】 Mega Man's Mission

    传送门 Description 你要杀n个怪,每杀掉一个怪那个怪会掉落一种武器,这种武器可以杀死特定的怪.游戏初始你有一把武器,能杀死一些怪物.每次只能杀一只,求有多少种杀怪方法. Input 多组数 ...

  9. UVA - 11795 状压DP

    #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #i ...

随机推荐

  1. html5,表格与框架综合布局

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  2. 四种MySQL存储引擎

    前言 数据库存储引擎是数据库底层软件组织,数据库管理系统(DBMS)使用数据引擎进行创建.查询.更新和删除数据.不同的存储引擎提供不同的存储机制.索引技巧.锁定水平等功能,使用不同的存储引擎,还可以 ...

  3. Office 2007在安装过程中出错-解决办法

    1, 可能是因为c:\program files\common files\microsoft Shared\web server Extensions\40\bin目录下缺少Fp4autl.dll, ...

  4. Ubuntu检测磁盘是否挂载

    Ubuntu默认不自动挂载磁盘. 只是学习Bash使用,需优化如使用 # file: mountAll.sh # include color support # a list of variables ...

  5. Sublime Text设置快捷键让html文件在浏览器打开

    一.安装View In Browser插件 快捷键 Ctrl+Shift+P(菜单栏Tools->Command Paletter),输入 pcip选中Install Package并回车,输入 ...

  6. Java中多线程使用匿名内部类的方式进行创建3种方式

    /* * 匿名内部类的格式: */ public class ThreadDemo { public static void main(String[] args) { // 继承thread类实现多 ...

  7. 使用jprofiler8远程监控weblogic的配置方法

    jprofiler8的注册码:L-Larry_Lau@163.com#36573-fdkscp15axjj6#25257 未完待续

  8. SPOOL、SQLLOADER数据导出导入的一点小总结

    1.SQLLOADER的CONTROL文件 //**************************************************************************** ...

  9. 【jqGrid for ASP.NET MVC Documentation】.学习笔记.6.分层

    1 两级分层 每个父 grid 的行,都能有子 grid .这被叫做 层次,它用来显示相关的 表,主信息 –> 明细信息等. } 一旦你为 父子 grid 都定义了 Models ,下一步就是设 ...

  10. Zero_qiqi DIV模式的省市区三级联动

    1].[代码] [HTML]代码 跳至 [1] [2] [3] [4] [5] [6] ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ...