就是改成把一个字符串改成三进制状压,然后分成前5位,后5位统计,

然后直接统计 f[i][j][k]代表,后5局状压为k的,前5局比和j状态比输了5局的有多少个人

复杂度是O(T*30000*25*m)m比较小,也就最多几十吧,将将过

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4. #include <iostream>
  5. #include <cstdlib>
  6. #include <vector>
  7. #include <cmath>
  8. #include <queue>
  9. #include <map>
  10. #include <string>
  11. using namespace std;
  12. typedef long long LL;
  13. const int N=3e4+;
  14. const int M=;
  15. const int INF=0x3f3f3f3f;
  16. int get(int x,int y){
  17. int ret=;
  18. for(int k=;k<;++k){
  19. int dig0=x%,dig1=y%;
  20. if(dig0==(dig1+)%)++ret;
  21. x/=,y/=;
  22. }
  23. return ret;
  24. }
  25. vector<int> win[][M],lose[][M];
  26. int T,cas,n,a[N][],ret[N][],f[][M][M];
  27. char ch[];
  28. int main(){
  29. for(int i=;i<M;++i){
  30. for(int j=;j<M;++j){
  31. win[get(i,j)][i].push_back(j);
  32. lose[get(i,j)][j].push_back(i);
  33. }
  34. }
  35. scanf("%d",&T);
  36. while(T--)
  37. {
  38. scanf("%d",&n);
  39. for(int i=;i<n;++i)
  40. {
  41. scanf("%s",ch);
  42. for(int j=;j<;++j)
  43. {
  44. if(ch[j]=='R')a[i][j]=;
  45. else if(ch[j]=='P')a[i][j]=;
  46. else a[i][j]=;
  47. }
  48. }
  49. memset(f,,sizeof(f));
  50. memset(ret,,sizeof(ret));
  51. for(int i=;i<n;++i)
  52. {
  53. int mask0=,mask1=;
  54. for(int j=;j<;++j)mask0=mask0*+a[i][j];
  55. for(int j=;j<;++j)mask1=mask1*+a[i][j];
  56. for(int j=;j<=;++j)
  57. {
  58. for(int k=;k<lose[j][mask0].size();++k)
  59. {
  60. int t=lose[j][mask0][k];
  61. ++f[j][t][mask1];
  62. }
  63. }
  64. }
  65. for(int i=;i<n;++i){
  66. int mask0=,mask1=;
  67. for(int j=;j<;++j)mask0=mask0*+a[i][j];
  68. for(int j=;j<;++j)mask1=mask1*+a[i][j];
  69. for(int s0=;s0<=;++s0)
  70. for(int s1=;s1<=;++s1){
  71. for(int k=;k<win[s1][mask1].size();++k){
  72. int t=win[s1][mask1][k];
  73. ret[i][s0+s1]+=f[s0][mask0][t];
  74. }
  75. }
  76. --ret[i][];
  77. }
  78. printf("Case #%d:\n",++cas);
  79. for(int i=;i<n;++i){
  80. for(int j=;j<;++j)
  81. printf("%d ",ret[i][j]);
  82. printf("%d\n",ret[i][]);
  83. }
  84. }
  85. return ;
  86. }

SDUT 3568 Rock Paper Scissors 状压统计的更多相关文章

  1. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  2. Gym - 101667H - Rock Paper Scissors FFT 求区间相同个数

    Gym - 101667H:https://vjudge.net/problem/Gym-101667H 参考:https://blog.csdn.net/weixin_37517391/articl ...

  3. FFT(Rock Paper Scissors Gym - 101667H)

    题目链接:https://vjudge.net/problem/Gym-101667H 题目大意:首先给你两个字符串,R代表石头,P代表布,S代表剪刀,第一个字符串代表第一个人每一次出的类型,第二个字 ...

  4. Gym101667 H. Rock Paper Scissors

    将第二个字符串改成能赢对方时对方的字符并倒序后,字符串匹配就是卷积的过程. 那么就枚举字符做三次卷积即可. #include <bits/stdc++.h> struct Complex ...

  5. 【题解】CF1426E Rock, Paper, Scissors

    题目戳我 \(\text{Solution:}\) 考虑第二问,赢的局数最小,即输和平的局数最多. 考虑网络流,\(1,2,3\)表示\(Alice\)选择的三种可能性,\(4,5,6\)同理. 它们 ...

  6. 题解 CF1426E - Rock, Paper, Scissors

    一眼题. 第一问很简单吧,就是每个 \(\tt Alice\) 能赢的都尽量让他赢. 第二问很简单吧,就是让 \(\tt Alice\) 输的或平局的尽量多,于是跑个网络最大流.\(1 - 3\) 的 ...

  7. HDOJ(HDU) 2164 Rock, Paper, or Scissors?

    Problem Description Rock, Paper, Scissors is a two player game, where each player simultaneously cho ...

  8. HDU 2164 Rock, Paper, or Scissors?

    http://acm.hdu.edu.cn/showproblem.php?pid=2164 Problem Description Rock, Paper, Scissors is a two pl ...

  9. 1090-Rock, Paper, Scissors

    描述 Rock, Paper, Scissors is a classic hand game for two people. Each participant holds out either a ...

随机推荐

  1. Android中使用HTTP和HttpClient进行通信

    /** * 使用HTTP的Get方式进行数据请求 */ protected void httpGet() { /** * 进行异步请求 */ new AsyncTask<String, Void ...

  2. [GCJ]Password Attacker

    https://code.google.com/codejam/contest/4214486/dashboard#s=p0 排列组合.DP递推式,如下代码.dp[m][n]表示长度为n的字符串里有m ...

  3. shutdown -s -t

    import java.io.*; import java.awt.*; public class HackDemo{ public static void main(String args[])th ...

  4. 77. Combinations

    题目: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For ex ...

  5. 6、JPA_映射单向多对一的关联关系(n的一方有1的引用,1的一方没有n的集合属性)

    单向多对一的关联关系 具体体现:n的一方有1的引用,1的一方没有n的集合属性 举个例子:订单Order对顾客Customer是一个单向多对一的关联关系.Order是n的一方,有对Customer的引用 ...

  6. ubuntu创建用户

    Linux 系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统.用户的账号 一方面可以帮助系统管理员对使用系统的用户进 ...

  7. asp.net Twilio

    Imports System.Net Imports System.Text Imports Twilio Public Class clsTwilioSMS Public Shared Functi ...

  8. Zookeeper、HBase的伪分布

    1.Zookeeper伪分布的部署(3个节点) 所谓的“伪分布式集群”就是在一台服务器中,启动多个Zookeeper实例.“完全分布式集群”是每台服务器,启动一个Zookeeper实例. 1.1.解压 ...

  9. jquery在线教程

    http://www.runoob.com/jquery/jquery-slide.htmlhttp://www.w3school.com.cn/jquery/http://www.phpstudy. ...

  10. scrapy wiki资料汇总

    See also: Scrapy homepage, Official documentation, Scrapy snippets on Snipplr Getting started If you ...