Solution

前缀和搞一下即可

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. const int N = 1000005;
  5. int T,n,m,p[N],a[N][26],ans[26];
  6. char s[N];
  7. signed main() {
  8. ios::sync_with_stdio(false);
  9. cin>>T;
  10. while(T--) {
  11. cin>>n>>m>>s+1;
  12. for(int i=1;i<=m;i++) cin>>p[i];
  13. ++m;
  14. p[m]=n;
  15. for(int i=1;i<=n;i++) {
  16. for(int j=0;j<26;j++) a[i][j]=a[i-1][j]+(s[i]-'a'==j);
  17. }
  18. for(int i=1;i<=m;i++) {
  19. for(int j=0;j<26;j++) ans[j]+=a[p[i]][j];
  20. }
  21. for(int i=0;i<26;i++) cout<<ans[i]<<" ";
  22. cout<<endl;
  23. memset(ans,0,sizeof ans);
  24. for(int i=1;i<=n;i++) {
  25. p[i]=ans[i]=s[i]=0;
  26. memset(a[i],0,sizeof a[i]);
  27. }
  28. }
  29. }

[CF1311C] Perform the Combo的更多相关文章

  1. Codeforces Round #624 (Div. 3) C. Perform the Combo(前缀和)

    You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...

  2. codeforce 1311 C. Perform the Combo 前缀和

    You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...

  3. Codeforces补题2020.2.28(Round624 Div 3)

    A.Add Odd or Subtract Even 签到题~ #include<bits/stdc++.h> using namespace std; int T; int a,b; i ...

  4. Codeforces Round #624 (Div. 3)(题解)

    Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...

  5. Codeforces Round #624 (Div. 3)(题解)

    A. Add Odd or Subtract Even 思路: 相同直接为0,如果两数相差为偶数就为2,奇数就为1 #include<iostream> #include<algor ...

  6. Codeforces #624 div3 C

    You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...

  7. jquery Combo Select 下拉框可选可输入插件

    Combo Select 是一款友好的 jQuery 下拉框插件,在 PC 浏览器上它能模拟一个简单漂亮的下拉框,在 iPad 等移动设备上又能回退到原生样式.Combo Select 能够对选项进行 ...

  8. [转]Extjs combo数据绑定与获取

    原文地址:http://www.cnblogs.com/loveme123/archive/2012/05/10/2494466.html 1. 配置combo: {                  ...

  9. CDN的combo技术能把多个资源文件合并引用,减少请求次数

    CDN的combo技术能把多个资源文件合并引用,减少请求次数.比如淘宝的写法: <link rel="stylesheet" href="//g.alicdn.co ...

随机推荐

  1. 解题笔记——NIT 遥远的村庄

    某个小镇有 N 个村庄,村庄编号1-N,给出 M 条单向道路,不存在环,即不存在 村庄A可以到达村庄B 且 村庄B也可以到达村庄A的情况.如果村庄A与村庄B之间存在一条单向道路,则说村庄A和村庄B之间 ...

  2. SpringBoot分布式篇Ⅶ --- 整合Dubbo

    在分布式系统中, 国内常用zookeeper+dubbo组合,而Spring Boot推荐使用全栈的Spring,Spring Boot,Spring Cloud. 分布式系统: 一.Zookeepe ...

  3. 深浅拷贝 集合(定义,方法) 函数(定义,参数,return,作用域) 初识

    深浅拷贝 在python中浅拷贝 a=[1,2,3,4,]b=a.copy()b[0]='3333'print(a) #[1, 2, 3, 4] 浅拷贝一层并不会对a造成变化print(b) #[33 ...

  4. Percona-XtraDB-Cluster-57 安装操作记录

    一.PXC集群的一些特性 Percona官网服务器位于境外,访问很困难.本次安装使用的是其官网提供的最新版本5.7.23-31.31.1.el7,当前日期为2018.10.10. PXC集群中,存储引 ...

  5. TS 原理详细解读(5)语法2-语法解析

    在上一节介绍了语法树的结构,本节则介绍如何解析标记组成语法树. 对应的源码位于 src/compiler/parser.ts. 入口函数 要解析一份源码,输入当然是源码内容(字符串),同时还提供路径( ...

  6. 温故知新,.NET 重定向深度分析

    在早期的.NET Framework程序员心里,重定向Redirect其实分为两种: Response.Redirect: Response对象的Redirect方法提供了一种实现客户端重定向的方法 ...

  7. Python用WMI模块获取windowns系统信息

    安装vmi https://pypi.org/project/WMI/#history 脚本如下: #!/usr/bin/env python #coding:utf- import wmi impo ...

  8. void * 和 void 在函数返回值中的区别

    一个很容易糊涂的问题. 在函数的返回值中, void 是没有任何返回值, 而 void * 是返回任意类型的值的指针. 还是看代码吧: #include <stdlib.h> #inclu ...

  9. Spring Boot自动装配原理源码分析

    1.环境准备 使用IDEA Spring Initializr快速创建一个Spring Boot项目 添加一个Controller类 @RestController public class Hell ...

  10. Java中的8种基本数据类型

    JAVA中的8种基本数据类型:byte short int long float double char boolean 特别说明: 1)char类型占2个字节,可以表示汉字.汉字和英文字符都占2个字 ...