H CodeForces 159C String Manipulation 1.0
来源:互联网 发布:虚拟货币挖矿网站源码 编辑:程序博客网 时间:2024/06/05 05:37
该题跟前面的POJ 2886蛮像的·~给出了相对位置·~处理处绝对位置就好了·~
因为空间问题。。所以建了26个树状数组,然后二分找答案即可
/*===============*\| *** *** *** *** || * ** * * * || *** *** * *** || ID: ZERO || LANG: C++ |\*===============*/#include <vector>#include <map>#include <set>#include <deque>#include <stack>#include <bitset>#include <algorithm>#include <sstream>#include <iostream>#include <cstdio>#include <queue>#include <cmath>#include <cstdlib>#include <cstring>#include <ctime>#include <string>#include <cassert>using namespace std;#define maxn 200001#define mod (int)(1e9+7)int tree[28][maxn];int lowbit(int x){ return x&(-x);}void add(int x,int v,int *arr){ while(x<=maxn-1){ arr[x]+=v; x+=lowbit(x); }}int sumit(int x,int *arr){ int sum=0; while(x>0){ sum+=arr[x]; x-=lowbit(x); } return sum;}int find(int nn,int *arr,int ll,int rr){ int l,r,ans; l=ll,r=rr; int mid=(l+r)/2; while(r>l+1){ mid=(l+r)/2; ans=sumit(mid,arr); if(ans>nn) r=mid-1; else if(ans<nn)l=mid+1; else r=mid; } if(sumit(l,arr)==nn) return l; if(sumit(mid,arr)==nn) return mid; return r;}char s[maxn];int main(){ int i,j,k; while(~scanf("%d",&k)){ scanf("%s",s); int len=strlen(s); int n; scanf("%d",&n); for(i=0;i<k;i++){ for(j=0;j<len;j++){ add(i*len+j+1,1,tree[s[j]-'a']); s[i*len+j]=s[j]; } } char temp[2]; int nn; while(n--){ scanf("%d%s",&nn,temp); int now=find(nn,tree[temp[0]-'a'],1,k*len);//二分找绝对位置 s[now-1]=0;//标记掉该点 add(now,-1,tree[temp[0]-'a']);//相应在数组中减掉该点 } for(i=0;i<k*len;i++){ if(s[i]) printf("%c",s[i]);//未标记则输出 } printf("\n"); } return 0;}
- H CodeForces 159C String Manipulation 1.0
- B - String Manipulation 1.0-CodeForces 159C
- 【CodeForces 159C】String Manipulation 1.0(字符串处理)
- codeforces 之 C. String Manipulation 1.0
- CF 159C String Manipulation 1.0
- VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0
- String Manipulation
- vector—— String Manipulation 1.0
- c string.h
- C中string.h
- c library-string.h
- c<string.h>函数
- Java String Manipulation
- Bash string manipulation
- String Manipulation - strtok
- C函数库介绍: string.h、mem.h
- C函数库介绍: string.h、mem.h
- C中string.h和stdlib.h
- 一种不错的从SQLServer转成Mysql数据库的方法
- SKB包的接收-----从网卡驱动到TCP层的处理流程
- Linux下的Nutch 1.4 安装配置
- emcv移植到DM642
- JDBC性能优化
- H CodeForces 159C String Manipulation 1.0
- Nginx搭建HTTPS服务器
- 应用run后Launcher中没有,也没有launching的原因
- Access/SqlServer->MYSQL的工具
- 我心目中的UBIFS之wandering tree
- win7 异步socket发生问题
- Linux netfilter 深度解析-对比Cisco 的ACL
- fixe repo sysnc err:Exited sync due to gc errors on Ubuntu 10.04 LTS
- 求和(单例模式,初始化列表,容器,迭代器)