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. 使用Allure+testNG自动生成漂亮强大的测试用例报告

    最近领导让我找一个可以每次打包自动生成测试用例的东西,jenkins或者idea都可以, 最后找到了这个allure,也踩了很多坑,废话不多说!,总结一下: 1 使用原生allure 添加依赖: &l ...

  2. RSYNC 同步工具

    Rsync 数据同步工具 一.Rsync简介 1.检测一下你的机器上是否已经安装  --->可以通过yum安装  或者  源码 Server  192.168.201.151 Client    ...

  3. 前端性能优化之利用 Chrome Dev Tools 进行页面性能分析

    背景 我们经常使用 Chrome Dev Tools 来开发调试,但是很少知道怎么利用它来分析页面性能,这篇文章,我将详细说明怎样利用 Chrome Dev Tools 进行页面性能分析及性能报告数据 ...

  4. java编写杨辉三角

    import java.util.Scanner; /* *计算杨辉三角: * 规律:两边都是1 * 从第三行开始,上一行的前一个元素+与其并排的元素等于下面的元素 * 例如: * 1 * 11 * ...

  5. 实验17:NAT

    实验14-1:静态NAT 配置 Ø    实验目的通过本实验可以掌握(1)静态NAT 的特征(2)静态NAT 基本配置和调试 Ø    拓扑结构 实验步骤n    步骤1:配置路由器R1 提供NAT ...

  6. 【2020-02-11】1346. Check If N and Its Double Exist

    更多LeetCode解题详解 Easy Given an array arr of integers, check if there exists two integers N and M such ...

  7. pandas使用的25个技巧

      本文翻译自https://nbviewer.jupyter.org/github/justmarkham/pandas-videos/blob/master/top_25_pandas_trick ...

  8. ReLU函数

    Rectifier(neural networks) 在人工神经网络中,rectfier(整流器,校正器)是一个激活函数,它的定义是:参数中为正的部分. , 其中,x是神经元的输入.这也被称为ramp ...

  9. python练习——第2题

    原GitHub地址:https://github.com/Yixiaohan/show-me-the-code 题目:将 0001 题生成的 200 个激活码(或者优惠券)保存到 MySQL 关系型数 ...

  10. Go语言实现:【剑指offer】顺时针打印矩阵

    该题目来源于牛客网<剑指offer>专题. 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字. 例如,如果输入如下4 X 4矩阵:1 2 3 4 5 6 7 8 9 10 11 ...