[CF1311C] Perform the Combo

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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #624 (Div. 3)(题解)
Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...
- Codeforces Round #624 (Div. 3)(题解)
A. Add Odd or Subtract Even 思路: 相同直接为0,如果两数相差为偶数就为2,奇数就为1 #include<iostream> #include<algor ...
- Codeforces #624 div3 C
You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...
- jquery Combo Select 下拉框可选可输入插件
Combo Select 是一款友好的 jQuery 下拉框插件,在 PC 浏览器上它能模拟一个简单漂亮的下拉框,在 iPad 等移动设备上又能回退到原生样式.Combo Select 能够对选项进行 ...
- [转]Extjs combo数据绑定与获取
原文地址:http://www.cnblogs.com/loveme123/archive/2012/05/10/2494466.html 1. 配置combo: { ...
- CDN的combo技术能把多个资源文件合并引用,减少请求次数
CDN的combo技术能把多个资源文件合并引用,减少请求次数.比如淘宝的写法: <link rel="stylesheet" href="//g.alicdn.co ...
随机推荐
- Linux防火墙之iptables常用扩展匹配条件(二)
上一篇博文我们讲到了iptables的一些常用的扩展匹配模块以及扩展模块的一些选项的说明,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/12273755.htm ...
- 【存储类、链接、存储管理】分配内存:malloc()、free()
一.使用库函数:malloc()分配管理内存 (一)标识符(Identifier) 1. 定义变量时,使用了诸如 a.abc.mn123 这样的名字,它们都是程序员自己起的,一般能够表达出变量的作用, ...
- python中Threadlocal变量
在多线程环境下,每个线程都有自己的数据.一个线程使用自己的局部变量比使用全局变量好,因为局部变量只有线程自己能看见,不会影响其他线程,而全局变量的修改必须加锁. 不加锁就会出现变量会被修改的问题,进而 ...
- how to convert wstring to string
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <local ...
- [git]git入门
usage: git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--ht ...
- How to setup backup by using EMC NW + EMC NMM for sqlserver failover cluster (not always on)
As we said, sqlsever fail over cluster is perviously version of always on. The HA was guarenteed by ...
- Go语言实现:【剑指offer】删除链表中重复的结点
该题目来源于牛客网<剑指offer>专题. 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中没有重复出现的数字. 示例 1: 输入: 1->2->3->3- ...
- Linux gcc链接动态库出错:LIBRARY_PATH和LD_LIBRARY_PATH的区别
昨天在自己的CentOs7.1上写makefile的时候,发现在一个C程序在编译并链接一个已生成好的lib动态库的时候出错.链接命令大概是这样的: [root@typecodes tcpmsg]# g ...
- Update、Insert注入技巧
title: Update.Insert注入技巧 date: 2017-10-23 18:07:57 tags: ["注入"] 审计了不少代码,再看代码的时候最多出现的就是注入,很 ...
- Python3(二) 表示‘组’的概念与定义
现实世界中总存在一组一组的事物, 一.列表的定义 type(['hello','world',1,9,True,False]) = <class 'list'> type([[1,2,3, ...