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 ...
随机推荐
- Spring boot 3.0 日志
spring boot 3.0 已经自己集成了日志功能 logback SpringBoot 启动时自动加载配置文件,配置文件的默认名称为: logback.xml 或 logback-test.x ...
- GIT安装及IDEA配置(GIT)
参考:https://blog.csdn.net/qq_40563761/article/details/91347443 1.安装git 2.idea下载GITHUB/GITEE插件 3.idea配 ...
- element el-table固定列凹陷问题
1.业务背景 列表显示字段过多,最后一栏操作列加固定显示,横向添加滚动条,在自测浏览器开发者模式时,发现固定列的最后一行出现了凹陷现象,网上查阅资料大多为在更新生命周期或者页面更新操作时重载页面,这些 ...
- LoginServlet类
import cn.itcast.dao.UserDao; import cn.itcast.domain.User; import javax.servlet.ServletException; i ...
- uboot之顶层Makefile
uboot版本信息 VERSION = 2006 主版本号 PATCHLEVEL = 03 补丁版本号 SUBLEVEL = 次此版本号 EXTRAVERSION = 附加版本 NAME ...
- Os-ByteSec
Os-ByteSec 目录 Os-ByteSec 1 信息收集 1.1 端口扫描 1.2 后台目录扫描 2 服务漏洞利用 2.1 检测smb服务漏洞 2.2 GetShell 3 提权 3.1 尝试提 ...
- Sublime Text 3怎么配置本地服务器?
1. 同样的我们需要借助一款插件来实现. 2.打开Sublime,使用快捷键[Ctrl + Shift + P]或者点击"Preferences"=> "Packa ...
- ABP微服务系列学习-对接前端界面
前面我们把后端的微服务架子基本搭建完成并成功启动了,现在我们可以对接前端界面了.这里我们直接用ABP模板里面的Angular的前端界面. 创建应用程序模板 使用ABPCli创建一个应用程序模板,前端选 ...
- redhat6.5_server_install
CentOS repo: wget http://mirrors.163.com/.help/CentOS6-Base-163.repo EPEL wget http://download.fedor ...
- 最全面 think php 实现微信公众号回复编号进行投票,自定义菜单功能
前期准备工作 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messag ...