[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 ...
随机推荐
- BP的matlab实现
%2015.04.26 Kang Yongxin ----v 2.0 %完成作业中BP算法,采用批量方式更新权重 %% %输入数据格式 %x 矩阵 : 样本个数*特征维度 %y 矩阵 :样本个数*类别 ...
- Java 中的各种锁和 CAS + 面试题
Java 中的各种锁和 CAS + 面试题 如果说快速理解多线程有什么捷径的话,那本文介绍的各种锁无疑是其中之一,它不但为我们开发多线程程序提供理论支持,还是面试中经常被问到的核心面试题之一.因此下面 ...
- python中的变量和字符串
一.变量 1.python变量 *变量用于存储某个或某些特定的值,它与一个特定标识符相关联,该标识符称为变量名称.变量名指向存储在内存中的值.在创建变量时会在内存中开辟一个空间.基于变量的数据类型,解 ...
- 为什么Netflix没有运维岗位?
Netflix 是业界微服务架构的最佳实践者,其基于公有云上的微服务架构设计.持续交付.监控.稳定性保障,都为业界提供了大量可遵从的原则和实践经验. 在运维这个细分领域,Netflix 仍然是最佳实践 ...
- OpenGL学习网址2
http://www.opengpu.org/forum.php?mod=viewthread&tid=7525
- 前端:CSS第四章第一节
块级元素一行只有一个,比如P标签 CSS层叠样式表,意思就是样式是可以叠加的,比如下面的代码 <style> .ok{ color: aqua; } .blue{ color: #5283 ...
- Django运行方式及处理流程总结(转发)
之前在网上看过一些介绍Django处理请求的流程和Django源码结构的文章,觉得了解一下这些内容对开发Django项目还是很有帮助的.所以,我按照自己的逻辑总结了一下Django项目的运行方式和对R ...
- 用EFCore的 FluentAPI 方式生成MySql 带注释的数据库表结构
采用的是net Core 3.1框架下的 的WebAPI项目. 1. 创建ASP.NET Core Web项目 2. 添加NuGet引用包,包如下 Microsoft.EntityFramewor ...
- nginx设置域名转发到指定端口
1.修改nginx.conf文件,将worker_processes 1 修改为 worker_processes auto 2.创建端口代理配置文件(域名地址如:xx.baidu.com , ...
- 13-MyBatis03(逆向工程)
MyBatis逆向工程 1.导入jar包 <dependency> <groupId>org.mybatis</groupId> <artifactId> ...