Solution

前缀和搞一下即可

#include <bits/stdc++.h>
using namespace std; #define int long long
const int N = 1000005;
int T,n,m,p[N],a[N][26],ans[26];
char s[N]; signed main() {
ios::sync_with_stdio(false);
cin>>T;
while(T--) {
cin>>n>>m>>s+1;
for(int i=1;i<=m;i++) cin>>p[i];
++m;
p[m]=n;
for(int i=1;i<=n;i++) {
for(int j=0;j<26;j++) a[i][j]=a[i-1][j]+(s[i]-'a'==j);
}
for(int i=1;i<=m;i++) {
for(int j=0;j<26;j++) ans[j]+=a[p[i]][j];
}
for(int i=0;i<26;i++) cout<<ans[i]<<" ";
cout<<endl;
memset(ans,0,sizeof ans);
for(int i=1;i<=n;i++) {
p[i]=ans[i]=s[i]=0;
memset(a[i],0,sizeof a[i]);
}
}
}

[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. Java 设计模式之工厂模式

    工厂模式(Factory Pattern)是 Java 中最常用的设计模式之一.这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式. 在工厂模式中,我们在创建对象时不会对客户端暴露创建逻 ...

  2. OpenDJ入门 | 5分钟快速入门Forgerock DS

    本教程为了让大家快速体验,故不做深入讲解,详细内容请留意后续进阶教程 介绍 OpenDJ是一个目录服务器,它实现了各种轻量级目录访问协议和相关标准,包括完全符合LDAPv3,但也支持目录服务标记语言( ...

  3. Java支付宝PC网站支付功能开发(详细教程)

    一.前言 本案例使用的是Java实现的.使用支付宝的沙盒环境示例.发布需要换成正式环境.这里就不作详细说明了 本代码适合用来做参考,不要直接复制去使用. 没有账号的需要去平台注册一个: 登录支付宝开发 ...

  4. uredis ------ 异步 redis 封装的访问库(c++),基于hiredis.

    详见 github : https://github.com/uniqss/uredis 底层使用hiredis库,使用libuv库. 只支持异步 支持分表分库,一般是用玩家的ID去取模,比如分库10 ...

  5. qt客户端程序使用svg图片资源的几种方法

    直接使用svg格式文件资源的情况 1. 直接在UI控件属性面板中选择部分支持icon图标的控件的icon来源,这样图标可以显示 2.给toolbutton添加样式 qproperty-icon: ur ...

  6. [python之路]学习路线

    python基础 #为什么要学python?python在知名公司广泛应用,谷歌.cia.nasa.youtobe.dropbox.instagram.facebook.redhat.豆瓣.知乎.搜狐 ...

  7. 二维数组转稀疏数组、稀疏数组恢复二维数组(Java实现)

    public static void main(String[] args) { // 创建一个原始的二维数组 9*9 int chessArr1[][] = new int[9][9]; // 0表 ...

  8. [Effective Java 读书笔记] 第二章 创建和销毁对象 第二条

    第二条 遇到多个构造器参数时,可以考虑用构建器 当遇到有多个构造器参数时,常见的是用重叠构造器,即: public class TestClass{ public TestClass(int para ...

  9. 20200221--python学习第14天

    今日内容 带参数的装饰器:flash框架+django缓存+写装饰器实现被装饰的函数要执行N次 模块: os sys time datetime和timezone[了解] 内容回顾与补充 1.函数 写 ...

  10. centos 7 设置 本地更新源

    #yum-config-manager --disable \*--屏弊所有更新源#mkdir /r7iso# cd /run/media/{用户名}/CentOS\ 7\ x86_64/ #cp - ...