Gym-102141E
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的更多相关文章
- 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 ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
- 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)
Gym Class Accepts: 849 Submissions: 4247 Time Limit: 6000/1000 MS (Java/Others) Memory Limit: 65 ...
随机推荐
- Unix、Linux、Windows操作系统的区别
1.操作区别 原文地址: https://blog.csdn.net/qq_41026740/article/details/96018808 linux区分大小写,windows在dos界面命令下不 ...
- 常用Oracle操作语句
--常用的字段类型有:varchar2,char,nchar,date,long,number,float,BLOB,CLOB --添加表字段 ); --修改表字段 ); --删除表字段 alter ...
- CF1086F Forest Fires
CF1086F Forest Fires 有点意思的题目 直接统计每个格子的val是非常难办的.很难知道每秒新出来多少个格子 设$F[i]$表示,前i时刻覆盖的格子的数量 则,$ans=\sum_{i ...
- mysql中的字符串截取和替换
-- 替换 replace(字段名,"需要替换的字符","替换的字符") mysql里replace不支持正则匹配 mysql> set @needRep ...
- git push到多个不同的远程仓库
1.若现在本地有一个已经和github远程仓库关联好的本地仓库,平时都会将本地仓库push到github上. 2.有一天突然发现"码云"这个远程仓库网站,咦!这个还可以创建priv ...
- markdown实现页内目录跳转
1.实现页内目录跳转 语法: 页面首部添加目录:[目录](#jump_id) 页面内部锚点:<span id='jump_id'>标题</span>
- <每日一题>题目14:拷贝的问题
''' 拷贝的问题 引用:无论怎么变都一起变 浅拷贝:只拷贝父对象,不会拷贝父对象中的子对象 深拷贝:完全拷贝,重新划分内存空间 ''' 具体如下图: 题目: #求a.b.c.d的值 import c ...
- idea创建web项目,springboot项目,maven项目
web项目搭建 https://www.cnblogs.com/jxldjsn/p/8203859.html
- JavaScript特效源码(5、背景特效)
1.数字时钟 背景时钟[好大的钟][推荐][共1步] ====1.以下是这个效果的全部代码.[最好从一个空页面开始] <html> <head> <TITLE>背景 ...
- Luogu P2458 [SDOI2006]保安站岗(树形dp)
P2458 [SDOI2006]保安站岗 题意 题目描述 五一来临,某地下超市为了便于疏通和指挥密集的人员和车辆,以免造成超市内的混乱和拥挤,准备临时从外单位调用部分保安来维持交通秩序. 已知整个地下 ...