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. 《ASP.NET Core 高性能系列》ASP.NET Core的启动过程(1)

    一.一切从头开始 简述:知道事情的真相就应该从头 开始,下面我们代码先行 public class Program { public static void Main(string[] args) { ...

  2. pycharm 固定模板使用者和日期

    如上图修改就可以正常修改模板了修改后每创建一个python文件就会是这种效果

  3. static静态变量在c++类中的应用实例

    这个static 如果写在类中,那么就可以得到一个局部的静态变量,也就是说可以实现在类内保存某个特殊值不随函数释放而消失的作用.应用中由于赋初值的位置不对而报错,错误提示为:“无法解析外部符号 ... ...

  4. 【WPF学习】第三十章 元素绑定——绑定到非元素对象

    前面章节一直都在讨论如何添加链接两个各元素的绑定.但在数据驱动的应用程序中,更常见的情况是创建从不可见对象中提取数据的绑定表达式.唯一的要求是希望显示的信息必须存储在公有属性中.WPF数据绑定数据结构 ...

  5. python 动态导包

    python 包简介 基本导包/模块 import 动态导包/模块 __import__   importlib 1. python 包简介 包是一个分层次的文件目录结构,它定义了一个由模块及子包,和 ...

  6. (数据科学学习手札75)基于geopandas的空间数据分析——坐标参考系篇

    本文对应代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 在上一篇文章中我们对geopandas中的数据结 ...

  7. Windows API 教程(九) 网络编程

    茵蒂克丝 基础概念 ip 地址 服务端与客户端 Socket 基础概念 头文件和库文件 常用函数 WSAStartup ( ) 函数 WSACleanup ( ) 函数 Socket ( ) 函数 c ...

  8. C语言实现查询whois

    #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <stdl ...

  9. 关于将笔记本电脑作为wifi热点的详细步骤

    常规做法直接度娘.如果出现无法打开wifi功能,可找对应解决方法. 1.先检查网卡是否支持承载网络,检查方法为在cmd中使用管理员权限运行,输入netsh wlan show drivers.查看支持 ...

  10. Codeforces 1304E 1-Trees and Queries (树上距离+思维)(翻译向)

    题意 给你一棵树,q个询问(x,y,a,b,k),每次问你如果在(x,y)加一条边,那么a到b能不能走k步,同一个点可以走多次 思路(翻译题解) 对于一条a到b的最短路径x,可以通过左右横跳的方法把他 ...