字符串处理 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. 删掉该字符,同时,他 ...
随机推荐
- TestNG demo
下载TestNG的归档文件 下载最新版本的TestNG的jar文件,详细请点击访问 http://www.testng.org..在写这篇教程的时候,我下载TestNG中-6.8.jar,并将 tes ...
- 【Android】Android聊天机器人实现
昨天看到一个Android视频教程讲图灵机器人.那个API接口用起来还是挺方便的,就准备自己动手做一个了. 另外自己还使用了高德地图的API接口用于定位(曾经用过高德的接口,比X度方便) 大体流程: ...
- Spring源码深度解析——笔记
1.spring容器的基本用法 xml配置 <bean id="myTestBean" class="bean.MyTestBean"/> 调用 B ...
- 通过定时任务 bash 脚本 控制 进程 的 执行时间
通过定时任务 bash 脚本 控制 进程 的 执行时间
- CWnd中PreCreateWindow、PreSubclassWindow、SubclassWindow
原文链接:http://blog.chinaunix.net/uid-14607221-id-2794642.html 1. PreCreateWindow: Called by the framew ...
- axios基于常见业务场景的二次封装
axios axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中.在前端框架中的应用也是特别广泛,不管是vue还是react,都有很多项目用axios作为网络 ...
- ubuntu主板信息
root:~# sudo dmidecode |grep -A16 "System Information$"sudo: 无法解析主机:phone-TPOWER-X79System ...
- SpringBoot启动跟踪
程序启动入口 @SpringBootApplication public class Chapter001Application { public static void main(String[] ...
- Silverlight中使用MVVM(4)
Silverlight中使用MVVM(1)--基础 Silverlight中使用MVVM(2)—提高 Silverlight中使用MVVM(3)—进阶 Silverlight中使用MVVM(4)—演练 ...
- 通过Oracle sql developer从sqlserver迁移数据到oracle
通过Oracle sql developer工具从sqlserver迁移数据到oracle 序言 一般情况下,sqlserver数据迁移到oracle,我们可以使用ODI来进行.但ODI的安装.配置. ...