字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String
/*
题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果
字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录
每个转换的次数,把每次要反转的反转就不超时了:)
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std; const int MAXN = 2e5 + ;
const int INF = 0x3f3f3f3f;
char s[MAXN];
int to[MAXN]; int main(void) //Codeforces Round #297 (Div. 2) B. Pasha and String
{
int m;
scanf ("%s", s + );
int len = strlen (s + );
scanf ("%d", &m);
while (m--)
{
int p; scanf ("%d", &p);
int q = len - p + ;
to[p]++;
} int sum = ;
for (int i=; i<=len/; ++i)
{
sum += to[i];
if (sum & ) swap (s[i], s[len-i+]);
}
printf ("%s", s + ); return ;
} /*
abcdef
1
2
vwxyz
2
2 2
abcdef
3
1 2 3
*/
字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String的更多相关文章
- Codeforces Round #297 (Div. 2)B. Pasha and String 前缀和
Codeforces Round #297 (Div. 2)B. Pasha and String Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #297 (Div. 2)E. Anya and Cubes 折半搜索
Codeforces Round #297 (Div. 2)E. Anya and Cubes Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx ...
- Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx ...
- Codeforces Round #297 (Div. 2)C. Ilya and Sticks 贪心
Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- BFS Codeforces Round #297 (Div. 2) D. Arthur and Walls
题目传送门 /* 题意:问最少替换'*'为'.',使得'.'连通的都是矩形 BFS:搜索想法很奇妙,先把'.'的入队,然后对于每个'.'八个方向寻找 在2*2的方格里,若只有一个是'*',那么它一定要 ...
- 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks
题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...
- 模拟 Codeforces Round #297 (Div. 2) A. Vitaliy and Pie
题目传送门 /* 模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢 题目倒是很长:) */ #include <cstdio> #include <algorithm> ...
- Codeforces Round #184 (Div. 2) E. Playing with String(博弈)
题目大意 两个人轮流在一个字符串上删掉一个字符,没有字符可删的人输掉游戏 删字符的规则如下: 1. 每次从一个字符串中选取一个字符,它是一个长度至少为 3 的奇回文串的中心 2. 删掉该字符,同时,他 ...
随机推荐
- SpringBoot项目 部署到服务器的tomcat下
把spring-boot项目按照平常的web项目一样发布到tomcat容器下 一.修改pom文件 修改打包方式 修改或增加maven插件 注意: 二.移除嵌入式tomcat插件 三.添加servlet ...
- 【bzoj3210】花神的浇花集会
将(x,y)转化成(x+y,x-y)可以将切比雪夫距离转化成曼哈顿距离(自己推一推) A.B的切比雪夫距离就是A‘.B‘曼哈顿距离的一半. 那么可以将x.y分离处理,排序中位数即可. 注意如果最后选的 ...
- C语言操作SQLite数据库
SQLite头文件和源文件下载地址http://www.sqlite.org/download.html 以下是示例代码 #include <stdio.h> #include " ...
- dotnet core 入门
之前一至用的dotnet 做开发,项目没有用过.netcore,现在看微软对dotnetcore的重视度越来越高,所以dotnetcore也是每一个.dotnet开发人员的一项必备技能.一个偶然的机会 ...
- Getting Started with xUnit.net (desktop)
https://xunit.github.io/docs/getting-started-desktop.html In this article, we will demonstrate getti ...
- Codeforces-914F Substrings in a String (Bitset求T串中S串出现次数)
之前有过区域赛,简化版问题: 给定一个小写字符组成的字符串S,(|S|<1e5,下标从1开始),现在有Q种操作,对于每个操作Q(Q<=1e5),输入opt, 如果opt==1,输入x,c, ...
- 「LuoguP3252」 [JLOI2012]树
Description 在这个问题中,给定一个值S和一棵树.在树的每个节点有一个正整数,问有多少条路径的节点总和达到S.路径中节点的深度必须是升序的.假设节点1是根节点,根的深度是0,它的儿子节点的深 ...
- ng2中文文档地址
https://angular.cn/docs/ts/latest/guide/displaying-data.html
- Flask log配置,实现按照日期自动生成日志文件
Flask自带了logger模块,用来方便程序员群众记录日志,这里粘贴出来的是一段代码,用来初始化日志各项配置参数,并根据日期自动生成日志文件. #log配置,实现日志自动按日期生成日志文件def m ...
- centos7 编译安装新版LNMP环境
centos7 编译安装新版LNMP环境 环境版本如下: 1.系统环境:Centos 7 x86_64 2.NGINX:nginx-1.11.3.tar.gz 3.数据库:mariadb-10.0.2 ...