SDUT 3568 Rock Paper Scissors 状压统计
就是改成把一个字符串改成三进制状压,然后分成前5位,后5位统计,
然后直接统计 f[i][j][k]代表,后5局状压为k的,前5局比和j状态比输了5局的有多少个人
复杂度是O(T*30000*25*m)m比较小,也就最多几十吧,将将过
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <string>
using namespace std;
typedef long long LL;
const int N=3e4+;
const int M=;
const int INF=0x3f3f3f3f;
int get(int x,int y){
int ret=;
for(int k=;k<;++k){
int dig0=x%,dig1=y%;
if(dig0==(dig1+)%)++ret;
x/=,y/=;
}
return ret;
}
vector<int> win[][M],lose[][M];
int T,cas,n,a[N][],ret[N][],f[][M][M];
char ch[];
int main(){
for(int i=;i<M;++i){
for(int j=;j<M;++j){
win[get(i,j)][i].push_back(j);
lose[get(i,j)][j].push_back(i);
}
}
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=;i<n;++i)
{
scanf("%s",ch);
for(int j=;j<;++j)
{
if(ch[j]=='R')a[i][j]=;
else if(ch[j]=='P')a[i][j]=;
else a[i][j]=;
}
}
memset(f,,sizeof(f));
memset(ret,,sizeof(ret));
for(int i=;i<n;++i)
{
int mask0=,mask1=;
for(int j=;j<;++j)mask0=mask0*+a[i][j];
for(int j=;j<;++j)mask1=mask1*+a[i][j];
for(int j=;j<=;++j)
{
for(int k=;k<lose[j][mask0].size();++k)
{
int t=lose[j][mask0][k];
++f[j][t][mask1];
}
}
}
for(int i=;i<n;++i){
int mask0=,mask1=;
for(int j=;j<;++j)mask0=mask0*+a[i][j];
for(int j=;j<;++j)mask1=mask1*+a[i][j];
for(int s0=;s0<=;++s0)
for(int s1=;s1<=;++s1){
for(int k=;k<win[s1][mask1].size();++k){
int t=win[s1][mask1][k];
ret[i][s0+s1]+=f[s0][mask0][t];
}
}
--ret[i][];
}
printf("Case #%d:\n",++cas);
for(int i=;i<n;++i){
for(int j=;j<;++j)
printf("%d ",ret[i][j]);
printf("%d\n",ret[i][]);
}
}
return ;
}
SDUT 3568 Rock Paper Scissors 状压统计的更多相关文章
- 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)
2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...
- Gym - 101667H - Rock Paper Scissors FFT 求区间相同个数
Gym - 101667H:https://vjudge.net/problem/Gym-101667H 参考:https://blog.csdn.net/weixin_37517391/articl ...
- FFT(Rock Paper Scissors Gym - 101667H)
题目链接:https://vjudge.net/problem/Gym-101667H 题目大意:首先给你两个字符串,R代表石头,P代表布,S代表剪刀,第一个字符串代表第一个人每一次出的类型,第二个字 ...
- Gym101667 H. Rock Paper Scissors
将第二个字符串改成能赢对方时对方的字符并倒序后,字符串匹配就是卷积的过程. 那么就枚举字符做三次卷积即可. #include <bits/stdc++.h> struct Complex ...
- 【题解】CF1426E Rock, Paper, Scissors
题目戳我 \(\text{Solution:}\) 考虑第二问,赢的局数最小,即输和平的局数最多. 考虑网络流,\(1,2,3\)表示\(Alice\)选择的三种可能性,\(4,5,6\)同理. 它们 ...
- 题解 CF1426E - Rock, Paper, Scissors
一眼题. 第一问很简单吧,就是每个 \(\tt Alice\) 能赢的都尽量让他赢. 第二问很简单吧,就是让 \(\tt Alice\) 输的或平局的尽量多,于是跑个网络最大流.\(1 - 3\) 的 ...
- HDOJ(HDU) 2164 Rock, Paper, or Scissors?
Problem Description Rock, Paper, Scissors is a two player game, where each player simultaneously cho ...
- HDU 2164 Rock, Paper, or Scissors?
http://acm.hdu.edu.cn/showproblem.php?pid=2164 Problem Description Rock, Paper, Scissors is a two pl ...
- 1090-Rock, Paper, Scissors
描述 Rock, Paper, Scissors is a classic hand game for two people. Each participant holds out either a ...
随机推荐
- hdu 1005 java(System.out.println();与System.out.println(“\n”);)
//package Main; import java.util.Scanner; public class Main { static int [][] mat=new int [2][2]; st ...
- nginx+apache+php+mysql服务器集群搭建
由于需要搭建了一个基本的服务器集群.具体的配置方案先不说了,到有时间的时候再介绍.下面介绍下整 个方案的优点. 我总共准备了四台阿里云的主机,架设分别是A,B1,B2,C,A在集群的最前面,B1和B2 ...
- 在Htmel中添加flash
> >
- C#基础练习(事件登陆案例)
Form1的后台代码: namespace _08事件登陆案例 { public partial class Form1 : Form { public Form1() ...
- kali 安装中文输入法
(1)apt-get install fcitx-googlepinyin (2)你希望继续执行吗?Y (3)连续执行数次 (4)init 6(命令行重启)
- 24个有用的PHP类库分享
目前,PHP是用于Web开发的最流行的脚本语言.你可以在互联网上随手找到关于PHP大量资料,包括文档.教程.工具等等.PHP不仅是一种功能丰富的语言,它还能帮助开发人员轻松地创建更好的网络环境.为了进 ...
- jsp获取struts2查询到的数据
1.在struts2的方法中利用查询语句查询到结果,然后再对结果进行封装,jsp根据封装获取相关信息 struts2的查询和封装方法: private List<FreeMarkerDetail ...
- Fucking "pkg-config not found"
If you got pkg-config not found error in gnu auto tools then, you must install the related librarys ...
- Drawable(4)LevelListDrawable
Levellist 显示时不像scale list 或 layout list那样要用代码设置一下,可以直接显示.改变level时才用代码. res:level_list.xml <?xml v ...
- JSTL、EL、ONGL、Struts标签的区别与使用
一.JSTL 来源 我们使用JSP开发信息展现非常方便,也可嵌入java代码用来实现相关逻辑,但同样带来了很多问题: jsp维护难度增加 出事提示不明确,不容易提示 分工不明确等 解决上面的问题可以 ...