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. 0929CSP-S模拟测试赛后总结

    70分31名滚粗. 赛后发现赛时得到的分数全都是暴力分…… T2打的三分跑都没跑……边界设错了……赛后稍微调了调多了15分…… 据说有15分的暴力分,那么另外15分就是只有一种选择的情况了…… (如果 ...

  2. 0919CSP-S模拟测试赛后总结

    60分-rank36,不出所料又炸了. 总是试图稳住成绩,但就是不能避免这样的大起伏.这样不行啊. T1可是道sb题啊……对着题干yy了一个多小时,正解基本都想到了,只差一个结构体排序. 然而即使我真 ...

  3. http://wiki.ros.org/navigation/Tutorials/RobotSetup

    http://wiki.ros.org/navigation/Tutorials/RobotSetup

  4. Centos7 下修改日期

    Centos7 下修改日期 2017年11月19日 19:37:47 harris135 阅读数:2851    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csd ...

  5. 软件-开发工具:Gradle

    ylbtech-软件-开发工具:Gradle Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化构建开源工具.它使用一种基于Groovy的特定领域语言(DSL)来声明 ...

  6. System.Drawing.Imaging.ImageFormat.cs

    ylbtech-System.Drawing.Imaging.ImageFormat.cs 1.程序集 System.Drawing, Version=4.0.0.0, Culture=neutral ...

  7. abstract类与interface

    抽象类: 1.用abstract修饰,抽象类中可以没有抽象方法,但抽象方法肯定在抽象类中,且抽象方法定义时不能有方法体:         2.抽象类不可以实例化只能通过继承在子类中实现其所有的抽象方法 ...

  8. 手把手教你 GitLab 的安装及使用(转)

    深山田 关注 2018.01.30 22:58 字数 1696 阅读 15559评论 2喜欢 15 前言 新入职公司,发现公司还在使用落后生产工具 svn,由于重度使用过 svn 和 git ,知道这 ...

  9. 配置vue项目的自定义config.js

    [1]不采用脚手架的config文件夹中的配置文件 [2]在static文件夹下,自定义一个congfig.js文件 // 配置开发环境下服务器地址 window.Glod = { pmsApiUrl ...

  10. C#の单例模式

    版本一: /// <summary>/// A simple singleton class implements./// </summary>public sealed cl ...