POJ 2960 博弈-简单SG
来源:互联网 发布:php curl 异步请求 编辑:程序博客网 时间:2024/05/22 11:04
记忆化搜索,数据太水,1<=h<=10000,但数组开100也能过。
STL的东西真不能用,太慢,用STL并且在搜索的函数里开10000的数组就RE了,用数组写的并且在搜索的函数里开10000的数组就A了。。
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>#include<iomanip>#include <set>#include <string>#include <vector>using namespace std;int s[1000],cnt;int sg[11500];int cal(int x){if(sg[x]!=-1) return sg[x];bool f[11500];memset(f,0,sizeof(f));for(int i=1;i<=cnt;++i)if(x-s[i]>=0){int tt=cal(x-s[i]);f[tt]=true;}for(int i=0;i<=10001;++i)if(!f[i])return sg[x]=i;}int main (){int k,m,l,temp;while(scanf("%d",&k)!=EOF){if(k==0) break;cnt=0;for(int i=1;i<=k;++i){scanf("%d",&m);s[++cnt]=m;}memset(sg,-1,sizeof(sg));sg[0]=0;string ans="";scanf("%d",&m);for(int i=1;i<=m;++i){scanf("%d",&l);int res=0;while(l--){scanf("%d",&temp);res=res^cal(temp);}if(res)ans+="W";else ans+="L";}cout<<ans<<endl;}return 0;}
- POJ 2960 博弈-简单SG
- poj-2960 S-Nim (博弈SG)
- SG博弈简单题
- POJ 2311 (博弈 sg函数)
- poj 2234基础Nim博弈||sg博弈
- HDU 1536 & POJ 2960 S-Nim(博弈 SG)
- poj 2960 S-Nim(博弈,SG值)
- poj 3480 John anti-SG博弈
- POJ 2311 Cutting Game (sg博弈)
- POJ 2311 Cutting Game 博弈,sg函数
- POJ 2505 博弈SG打表
- POJ 2484 简单博弈
- POJ 2484 简单博弈
- 【POJ 2960】SG函数
- poj-2960 SG函数
- POJ-3537 Crosses and Crosses (博弈, SG函数)
- POJ 3710 Christmas Game(Tarjan+博弈SG函数)
- hdu 1849 Rabbit and Grass SG定理(简单博弈)
- hdu2716水水哈希
- fedora10.0下安装gcc 和g++
- Android中资源文件的使用
- 密码代换技术验证
- UVA 11389——The Bus Driver Problem
- POJ 2960 博弈-简单SG
- 设计模式小结
- 函数参数传递的三种基本方式
- JS验证时间是否是2012-01-01
- android 打开GPS的2种方式
- Android开发之旅:android架构
- android分辨率(屏幕适配)
- ListView控件详解
- 高性能IO设计的Reactor和Proactor模式