[ An Ac a Day ^_^ ] CodeForces 525B Pasha and String 技巧
题意就是一次次翻转字符串 然后输出最终的字符串
暴力一发O(n*m)果然超时了
因为每次翻转的的都是a-1到对称位置
所以一个位置翻转两次等于没有操作
所以只需要记录一下len/2的位置前的操作次数
O(len/2)……
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
char str[];
bool vis[];
int main(){
gets(str);
int len=strlen(str);
int n,a;
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&a);
vis[a-]=!vis[a-];
}
int now=;
for(int i=;i<len/;i++){
now^=vis[i];
if(now) swap(str[len-i-],str[i]);
}
puts(str);
return ;
}
/* abcdef
1
2 vwxyz
2
2 2 abcdef
3
1 2 3 */
[ An Ac a Day ^_^ ] CodeForces 525B Pasha and String 技巧的更多相关文章
- codeforces B. Pasha and String
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters ...
- codeforces B. Pasha and String(贪心)
题意:给定一个长度为len的字符序列,然后是n个整数,对于每一个整数ai, 将字符序列区间为[ai,len-ai+1]进行反转.求出经过n次反转之后的序列! /* 思路1:将区间为偶数次的直接去掉!对 ...
- 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 ...
- Pasha and String(思维,技巧)
Pasha and String Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
- B. Pasha and String
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String
题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的 ...
- Codeforces 435B. Pasha Maximizes
简单贪心.... B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces 595B - Pasha and Phone
595B - Pasha and Phone 代码: #include<bits/stdc++.h> using namespace std; #define ll long long # ...
- Codeforces 595B. Pasha and Phone 容斥
B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard i ...
随机推荐
- wuzhicms 数据迁移策略
1,本地的域名或ip为特殊域名或ip,勿用 127.0.0.1 或 localhost 或192.168.1.101 等 2,导出数据库,替换所有域名为新域名 3,替换所有文件域名为新域名 4, ...
- Shell 脚本计算时间差
在shell脚本中统计程序执行完毕所需要的时间不像在java中使用System.currentTimeMillis()方便 稍微记录一下,以供备用,免得又去花时间想(统计程序执行消耗多少s): sta ...
- EasyCHM(CHM电子书制作工具) v3.84.545 绿色版
软件名称:EasyCHM(CHM电子书制作工具) v3.84.545 绿色版 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 2.78MB 图片预览: 软件 ...
- cout 格式化的一些方法
cout格式化的方式有很多,和C中的printf相比较,在实现方式上更加容易理解. 1.计数进制. 1.十六进制:hex 2.八进制:oct 3.十进制:dec(默认) 在控制进制的时候,可以使用两种 ...
- 敏捷开发(十一)- Scrum Sprint评审会议
本文主要是为了检测你对SCRUM 评审会议的了解和使用程度, 通过本文你可以检测一下 1.你们的SCRUM 评审会议的过程和步骤 2.SCRUM 评审会议的输出结果一.会议目的 ...
- 无线hacking系统—wifislax
简介 官方中文网站: http://wifislax.cn/ WiFiSlax 是在Slax基础上定制出来的,由西班牙开发.它包含了各种各样的安全和诊断工具.该发行主要的成名原因是把各种各样的非官方网 ...
- Python学习笔记——基础篇【第六周】——shutil模块
常用模块之shutil 高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length]) 将文件内容拷贝到另一个文件中,可以部分内容 def c ...
- @classmethod及@staticmethod方法浅析【python】
目前对于python中@classmethod 类方法和@staticmethod静态方法的有了一定的认识,之后有进一步的认识后继续记录. @classmethod :是和一个class类相关的方法, ...
- python的web开发环境Django配置
我的系统的windows10: 第一步,安装python3.5 第二步,配置django,如图所示,在python的安装目录下的Scripts里面执行:pip install Django,我这儿提示 ...
- Remote小Demo
Demo基于http://www.cnblogs.com/zhili/p/NETRemoting.html RemotingObj using System; using System.Collect ...