https://vjudge.net/problem/Gym-102141E

用set乱搞

#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<set>
#include<cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i) using namespace std;
char s[N];
int T,kase;
struct node{
int l,r;
bool operator < (const node &b) const{
if(r!=b.r) return r<b.r;
return l<b.l;
}
}; struct tree{
set<node>s;
void init(){
s.clear();
}
void insert(int l,int r){
s.insert({l,r});
}
void spilt(int x){
auto res=*s.lower_bound({-,x});
s.erase(res);
if(x!=res.l) s.insert({res.l,x-});
if(x!=res.r) s.insert({x+,res.r});
}
int query(int x){
auto it=s.lower_bound({-,x});
return (it->r)-(it->l)+;
}
}a[]; void in(int &x){
int y=;char c=getchar();x=;
while(c<''||c>''){if(c=='-')y=-;c=getchar();}
while(c<=''&&c>=''){ x=(x<<)+(x<<)+c-'';c=getchar();}
x*=y;
}
void o(int x){
if(x<){p('-');x=-x;}
if(x>)o(x/);
p(x%+'');
} int main(){
in(T);
while(T--){
scanf("%s",s);
int n=strlen(s),op,q,x,l=;
For(i,,)
a[i].init();
For(i,,n-)
if(s[i]!=s[i-]){
a[s[i-]-'A'].insert(l,i-);
l=i;
}
a[s[n-]-'A'].insert(l,n-);
in(q);
printf("Case %d:\n",++kase);
while(q--){
in(op);in(x);
if(op&)
o(a[s[x]-'A'].query(x)),p('\n');
else
a[s[x]-'A'].spilt(x),s[x]='#';
}
}
return ;
}

Gym-102141E的更多相关文章

  1. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

  10. 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)

    Gym Class  Accepts: 849  Submissions: 4247  Time Limit: 6000/1000 MS (Java/Others)  Memory Limit: 65 ...

随机推荐

  1. kubernetes 强制删除istio-system空间,强制删除pod

    加上这个选项 --grace-period=0 --force--grace-period=0 --force 先删除deployment,pod,svc再删除namespace > kubec ...

  2. VC++ COMBO BOX控件的使用

    1.你在编辑状态下点那个控件的向下的三角形,就出冒出来一个可以调高度的东东.将高度调高,否则在执行时会不能显示下拉选项.   2.为combo box添加选项,在编辑状态下选combo box控件的属 ...

  3. JS继承(简单理解版)

    童鞋们,我们今天聊聊js的继承,关于继承,平时开发基本用不到,但是面试没有不考的,我就想问,这是人干的事吗? 好吧,迫于社会主义核心价值观,我们今天就来简单说一说js的继承,谁让它是面向对象编程很重要 ...

  4. System.Web.Mvc.HttpPutAttribute.cs

    ylbtech-System.Web.Mvc.HttpPutAttribute.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, P ...

  5. (36)C# COM交互

    调用DLL [DllImport("standerMFC.dll")] public static extern int PReadUID(ref HHFC_SET stru); ...

  6. iOS扩展Extension之Today

    1.简介 扩展(Extension)是iOS 8中引入的一个新特性.扩展让app之间的数据交互成为可能.在iOS 8系统之前,每一个app在物理上都是彼此独立的,app之间不能互访彼此的私有数据.而在 ...

  7. Spring 基于Aspectj切面表达式(6)

    1 package com.proc; 2 3 import org.aspectj.lang.JoinPoint; 4 import org.aspectj.lang.ProceedingJoinP ...

  8. Map和Reduce函数

  9. UMP系统功能 容灾

  10. LINUX挂接UNIX系统NFS文件共享

    类似于windows的网络共享,UNIX(Linux)系统也有自己的网络共享,那就是NFS(网络文件系统),下面我们就以SUN Solaris2.8和REDHAT as server 3 为例简单介绍 ...