C - Perform the Combo

思路:当读到这个题的时候,第一反应就是枚举,但是,无线超时,没办法,那就变,利用前缀和,减少时间。

代码:

#include<iostream>
#include<string>
#include<algorithm>
#define MAX 200005
using namespace std;
long long str[MAX];
long long b[28];
char s[MAX]; int main(){
int t,n, m;
scanf("%d", &t);
while (t--){
memset(str, 0, sizeof str);
memset(b, 0, sizeof b);
scanf("%d%d", &n, &m);
scanf("%s", s + 1);
for (int i = 1; i <= m; ++i){
long long a;
scanf("%lld", &a);
str[a] ++;
}
for (int i = n - 1; i >= 1; i--)
str[i] += str[i + 1];
for (int i = 1; i <= n; ++i){
b[s[i] - 'a'] += str[i] + 1;
}
for (int i = 0; i < 26; ++i) {
printf("%lld ", b[i]);
}
printf("\n");
}
return 0;
}

C - 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. [CF1311C] Perform the Combo

    Solution 前缀和搞一下即可 #include <bits/stdc++.h> using namespace std; #define int long long const in ...

  4. 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 ...

  5. Codeforces Round #624 (Div. 3)(题解)

    Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...

  6. Codeforces Round #624 (Div. 3)(题解)

    A. Add Odd or Subtract Even 思路: 相同直接为0,如果两数相差为偶数就为2,奇数就为1 #include<iostream> #include<algor ...

  7. Codeforces #624 div3 C

    You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...

  8. jquery Combo Select 下拉框可选可输入插件

    Combo Select 是一款友好的 jQuery 下拉框插件,在 PC 浏览器上它能模拟一个简单漂亮的下拉框,在 iPad 等移动设备上又能回退到原生样式.Combo Select 能够对选项进行 ...

  9. [转]Extjs combo数据绑定与获取

    原文地址:http://www.cnblogs.com/loveme123/archive/2012/05/10/2494466.html 1. 配置combo: {                  ...

  10. CDN的combo技术能把多个资源文件合并引用,减少请求次数

    CDN的combo技术能把多个资源文件合并引用,减少请求次数.比如淘宝的写法: <link rel="stylesheet" href="//g.alicdn.co ...

随机推荐

  1. SpringBoot+Vue前后端分离项目,在过滤器取值为Null

    SpringBoot+Vue前后端分离项目,在过滤器取值为Null 是因为SessionID的问题,因为axios每次的请求都是一次新的sessionId,所以只需要在main.js下配置如下 axi ...

  2. SpringCloud 消费请求Eureka调用服务提供者报错

    SpringCloud 消费请求Eureka调用服务提供者报错 springCloud 2022.0.1 springboot 3.0.2 消费程序 通过eureka集群查询服务,根据eureka中注 ...

  3. 文盘Rust -- 本地库引发的依赖冲突

    作者:京东科技 贾世闻 问题描述 clickhouse 的原生 rust 客户端目前比较好的有两个clickhouse-rs 和 clickhouse.rs .clickhouse-rs 是 tcp ...

  4. 【TS】接口和接口继承

    接口 接口也相当于语法规范,在使用ts编写的时候,需要注重的就是数据类型以及语法规范,恰好这里提供了一个接口,在进行传值的时候,传值的类型以及字段必须符合我们预期的类型规范才可以,下面是代码演示 语法 ...

  5. 软件设计师考试备考之UML

    UML 统一建模语言是面向对象软件的标准化建模语言. 事务 结构事务 UML模型中的名称,它们通常是模型的静态部分,描述概念或物理元素 图形表示: 行为事务 UML模型中的动态部分.它们是模型中的动词 ...

  6. 【KAWAKO】将conda虚拟环境设置进jupyter-notebook

    目录 进入虚拟环境 安装ipykernel 将虚拟环境加入notebook的kernel 打开jupyter-notebook并使用 进入虚拟环境 conda activate audio 安装ipy ...

  7. JZOJ 捕老鼠

    题目 实际上经转换得: 给了 \(n(n \le 5 \times 10^5)\) 条线段,求覆盖 \([1..n]\) 需要的最少条数 分析 设 \(f_i\) 表示覆盖了 \([1..n]\) 时 ...

  8. Jetpack Compose学习(11)——Navigation页面导航的使用

    原文:Jetpack Compose学习(11)--Navigation页面导航的使用 - Stars-One的杂货小窝 在Android原生的View开发中的,也是有Navigation,原生我之后 ...

  9. 血药谷浓度能否区分经TNF拮抗剂诱导获得缓解和低活动度的RA患者

    血药谷浓度能否区分经TNF拮抗剂诱导获得缓解和低活动度的RA患者? Sanmarti R, et al. EULAR 2015. Present ID: FRI0133. 原文 译文 FRI0133 ...

  10. U-Boot-基础概念与学习分享

    U-Boot 基础概念与学习分享 Board: rockchip-px30, armv8, Cortex-A35 U-Boot: rockchip-linux/u-boot, branch next- ...