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 ...
随机推荐
- Android中使用HTTP和HttpClient进行通信
/** * 使用HTTP的Get方式进行数据请求 */ protected void httpGet() { /** * 进行异步请求 */ new AsyncTask<String, Void ...
- [GCJ]Password Attacker
https://code.google.com/codejam/contest/4214486/dashboard#s=p0 排列组合.DP递推式,如下代码.dp[m][n]表示长度为n的字符串里有m ...
- shutdown -s -t
import java.io.*; import java.awt.*; public class HackDemo{ public static void main(String args[])th ...
- 77. Combinations
题目: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For ex ...
- 6、JPA_映射单向多对一的关联关系(n的一方有1的引用,1的一方没有n的集合属性)
单向多对一的关联关系 具体体现:n的一方有1的引用,1的一方没有n的集合属性 举个例子:订单Order对顾客Customer是一个单向多对一的关联关系.Order是n的一方,有对Customer的引用 ...
- ubuntu创建用户
Linux 系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统.用户的账号 一方面可以帮助系统管理员对使用系统的用户进 ...
- asp.net Twilio
Imports System.Net Imports System.Text Imports Twilio Public Class clsTwilioSMS Public Shared Functi ...
- Zookeeper、HBase的伪分布
1.Zookeeper伪分布的部署(3个节点) 所谓的“伪分布式集群”就是在一台服务器中,启动多个Zookeeper实例.“完全分布式集群”是每台服务器,启动一个Zookeeper实例. 1.1.解压 ...
- jquery在线教程
http://www.runoob.com/jquery/jquery-slide.htmlhttp://www.w3school.com.cn/jquery/http://www.phpstudy. ...
- scrapy wiki资料汇总
See also: Scrapy homepage, Official documentation, Scrapy snippets on Snipplr Getting started If you ...