题意

\(yyb\)要去与\(m\)\((m\le100)\)个人玩游戏

由于\(yyb\)忙着切大火题,他没有太多的精力浪费在游戏上

所以仁慈的\(yyb\)决定放\(m\)个人一条生路,不吊打他们

然而\(yyb\)为了维护自己红太阳的形象,不能输,所以他希望与每个人玩游戏都能是平局

游戏很简单,就是石头剪刀布,\(yyb\)会与每个人玩\(n(n\le 20)\)场

只要双方赢的次数相同就视为平局

\(yyb\)非常的强,所以大家每一场比赛想出什么\(yyb\)一眼就看出来了

每个人的策略都是一个长度为\(n\)的序列

然后他觉得能用同一个长度为\(n\)的策略序列与每个人打平局

然而\(yyb\)并不满足与这些,他想知道自己有多少种方式打平,这样他就能知道别人比自己弱多少,从而增长自己的淫威

正如大家所知,\(yyb\)秒题入魔,懒得去想这个\(naive\)的比赛

所以请比他弱的你来帮他求出这个方案数

Sol

\(meet \ in \ the \ midlle\)

爆搜,把状态开\(vector\)压进\(map\)查询

# include <bits/stdc++.h>
# define RG register
# define IL inline
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
typedef vector <int> vi; IL int Input(){
RG int x = 0, z = 1; RG char c = getchar();
for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x * z;
} int win[3][3] = {{0, -1, 1}, {1, 0, -1}, {-1, 1, 0}};
int n, m, a[105][25], b[25], mid;
vi tmp;
map <vi, int> t;
ll ans; IL void Record(){
tmp.clear();
for(RG int i = 1; i <= m; ++i){
RG int cnt = 0;
for(RG int j = 1; j <= mid; ++j) cnt += win[a[i][j]][b[j]];
tmp.push_back(cnt);
}
++t[tmp];
} IL void Dfs1(RG int l){
if(l > mid){
Record();
return;
}
for(RG int i = 0; i < 3; ++i) b[l] = i, Dfs1(l + 1);
} IL void Calc(){
tmp.clear();
for(RG int i = 1; i <= m; ++i){
RG int cnt = 0;
for(RG int j = mid + 1; j <= n; ++j) cnt -= win[a[i][j]][b[j]];
tmp.push_back(cnt);
}
ans += t[tmp];
} IL void Dfs2(RG int l){
if(l > n){
Calc();
return;
}
for(RG int i = 0; i < 3; ++i) b[l] = i, Dfs2(l + 1);
} IL ll Solve(){
mid = (1 + n) >> 1;
Dfs1(1), Dfs2(mid + 1);
return ans;
} class EllysRPS{
public:
ll getCount(vector <string> s){
m = s.size(), n = s[0].size();
for(RG int i = 1; i <= m; ++i)
for(RG int j = 1; j <= n; ++j)
if(s[i - 1][j - 1] == 'R') a[i][j] = 0;
else a[i][j] = (s[i - 1][j - 1] == 'S') + 1;
return Solve();
}
};

TopCoder14580: EllysRPS的更多相关文章

  1. Meet in the middle学习笔记

    Meet in the middle(MITM) Tags:搜索 作业部落 评论地址 PPT中会讲的很详细 当搜索的各项互不影响(如共\(n\)个物品前\(n/2\)个物品选不选和后\(n/2\)个物 ...

随机推荐

  1. hive一些基本用法

    1.hive中的数据库表的类型有两种,一种是managed,一种是external  :managed表类型是指传入的数据放在hive默认的储存位置下,而external 表类型可以将数据 放在任意的 ...

  2. 2016级算法第六次上机-B.ModricWang's FFT : EASY VERSION

    1114 ModricWang's FFT EASY VERSION 思路 利用FFT做大整数乘法,实际上是把大整数变成多项式,然后做多项式乘法. 例如,对于\(1234\),改写成\(f(x)=1* ...

  3. 开源系统-edusoho在线教育

    #部署 ```bash [root@localhost ~]# docker run --name edusoho -tid         -p 9900:80         -e DOMAIN= ...

  4. SQL语句01

    SQL(Structured Query Language):结构化查询语言 SQL分类:    数据操纵语言DML(Data Manipulation Language)        SELECT ...

  5. 物联网学习之路——物联网通信技术:NBIoT

    NBIoT是什么 NB-IoT,Narrow Band Internet of Things,窄带物联网,是一种专为万物互联打造的蜂窝网络连接技术.顾名思义,NB-IoT所占用的带宽很窄,只需约180 ...

  6. win10 压缩包安装mysql8.0.11报错:Access denied for user 'root'@'localhost'

    按这篇:https://blog.csdn.net/Myuhua/article/details/84792121#commentsedit 这里精简下,还有update语句中authenticati ...

  7. iddler抓包过程以及fiddler抓包手机添加代理后连不上网解决办法

    转载自:https://blog.csdn.net/m0_37554415/article/details/80434477,感谢博主的热心分享 1.(1)电脑端打开安装好的的fiddler,打开To ...

  8. Mac下使用Wine安装文件内容搜索工具Search and Replace

    下载: (链接: https://pan.baidu.com/s/1mij7WX6 密码: xsu8) 安装: 1.安装Wine 参考:http://www.cnblogs.com/EasonJim/ ...

  9. Linux快速查看某条命令的版本和存放的位置(ls -l `which mvn`)

    输入: ls -l `which mvn` 如图:

  10. django notes 四: Writing views

    views 其实没什么可看的, 在  django  中 views 就是 controller, 是处理请求的, 就是一个普通的 python 方法. 一般从 request 中提取请求参数, 然后 ...