C - Perform the Combo
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的更多相关文章
- 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 ...
- [CF1311C] Perform the Combo
Solution 前缀和搞一下即可 #include <bits/stdc++.h> using namespace std; #define int long long const in ...
- 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 ...
随机推荐
- WPF 使用动画绘制一个点赞大拇指
效果图 好久没有写wpf了. 最近看到飞书的点赞动画非常有意思,决定试试,虽然不及飞书那样的绚丽,但是练手还是可以的,希望自己的手艺还在! 那么如何写一个这样的动画呢? 首先需要刨析这个动画的构成: ...
- spring security登录认证流程解析
转 https://blog.csdn.net/qq_37142346/article/details/80032336 1.说明 用户认证流程 认证结果如何在多个请求之间共享 获取认证用户信息.用户 ...
- 【已解决】csv数据导入sql by sqlyog 乱码+无法导入导入步骤分析等总结
csv数据导入sql 用sqlyog工具 首先是创建一个数据库 --> 然后右键点击数据库->选择创建表 ->表名自己写,让在引擎这里选择csv 然后注意 把非空都勾选了!不然会报错 ...
- 使用花生壳进行内网穿透实验SQLserver
在一次编写软件的过程中,想让远在河南的同学对试一试,但是他的电脑上没有与之对应的SQL数据库不能便不能够运行软件.于是我想到了远程连接.在使用花生壳的时候,遇到了一些问题,然而网络上并没有与之对应的解 ...
- cs 起源 fps 逆向
1.找到人物坐标X YZ2.找到鼠标X Y3.易语言读取人物坐标4.读取敌人坐标打开控制台服务器与客户端尽量找客户端 找到XYZ5.实时读取敌人坐标6.三角函数转换屏幕坐标FOV 视场角狙击枪找FOV ...
- TCP/IP 协议(10):TCP 协议一百问
TCP/IP 协议(10):TCP 协议一百问 杨领well 的 TCP/IP 协议专栏 TCP 协议部分一直没有更新,是因为我不确定到底应该怎么来介绍 TCP 协议才能干货满满.最后我决定以 Q&a ...
- JZOJ 3423.Vani和Cl2捉迷藏 & [CTSC2008]祭祀
\(\text{Problem}\) 求一个 \(DAG\) 的最长反链 \(\text{Solution}\) 由 \(Dilworth\) 定理只最长反链等于最小链覆盖 而原图的链是可相交的,所以 ...
- pytorch学习笔记一之张量
1. 张量¶ 1.1. 概述¶ 张量(tensor)是pytorch中的一种较为基础的数据结构,类比于numpy中的ndarrays,在pytorch中,张量可以在GPU中进行运算 通 ...
- 轻量级CI/CD发布部署环境搭建及使用_04_docker安装nexus3
轻量级CI/CD发布部署环境搭建及使用_04_配置宿主机的环境:jdk.maven.node.pythod2 尽自己的绵薄之力,为开源技术分享添砖加瓦 1,搜索nexus3 docker sear ...
- LeetCode-2043 两数相加题解
来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/simple-bank-system 题目描述 你的任务是为一个很受欢迎的银行设计一款程序,以自动 ...