字符串处理 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. 删掉该字符,同时,他 ...
随机推荐
- linux centos7 安装常用软件java,node,mysql,Seafile
linux centos7 安装常用软件java,node,mysql,Seafile 安装压缩解压缩软件 yum install -y unzip zip 安装git yum install -y ...
- 你的以太网速度足够快吗?四种更快的速度正在路上······
以太网的未来将远远超越下一个最快速度:为无处不在的网络协议绘制路径的网络project师们正在寻找新版本号来服务于各种应用程序. 在上周六的以太网联盟(一个行业组织,用于促进IEEE以太网标准)会议上 ...
- SSM整理笔记3——配置解析
github:https://github.com/lakeslove/SSM 项目的目录结构如下 首先,配置web.xml <?xml version="1.0" enco ...
- RabbitMQ Connector
https://ci.apache.org/projects/flink/flink-docs-master/dev/connectors/rabbitmq.html RabbitMQ Source ...
- 最短路Dijkstra算法的一些扩展问题
最短路Dijkstra算法的一些扩展问题 很早以前写过关于A*求k短路的文章,那时候还不明白为什么还可以把所有点重复的放入堆中,只知道那样求出来的就是对的.知其然不知其所以然是件容易引发伤痛的 ...
- POJ1759 Garland —— 二分
题目链接:http://poj.org/problem?id=1759 Garland Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- dedecms5.7二级域名文章图片不显示修改方法.相对路径改为绝对路径的方法
dedecms5.7(织梦CMS5.7)二级域名文章图片不显示修改方法.相对路径改为绝对路径的方法 dedecms升级到5.7SP1后,开启二级域名,你会发现,在二级域名下的文章,上传的图片地址都是: ...
- 一步一步学Silverlight 2系列(23):Silverlight与HTML混合之无窗口模式
概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...
- Android中android:visibility的3中属性的剖析
在Android中控件或者布局的可见性android:visibility有3中情况,他们分别是: View.VISIBLE,View.UNVISIBLE,View.GONE View.VISIBLE ...
- Tomcat 系统架构与设计模式之二
Tomcat 系统架构与设计模式,第 2 部分: 设计模式分析 来自:http://www.ibm.com/developerworks/cn/java/j-lo-tomcat2/ 这个分为两个部分的 ...