Codeforces Round #186 (Div. 2) / 313B Ilya and Queries (字符串处理)

SpringBoot集成ONLYOFFICE实现文档协作功能 在线文档协作是企业级应用开发中的核心需求,通过集成专业文档处理工具可以显著提升系统能力。ONLYOFFICE作为开源办公套件,提供接近原生Office的文档渲染和实时协作体验,特别适合需要内网部署或对数据隐私要求高的场景。本文详细介绍如何在SpringBoot项目中集成ONLYOFFICE Document Server,包括Docker部署方案、JWT安全配置、前后端对接实现等关键技术要点。通过实际项目验证,该方案能快速为系统添加专业的文档编辑、版本控制和权限管理功能,同时避免商业API的调用限制。 阅读详情

B. Ilya and Queries
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.

You've got string s = s1s2... sn (n is the length of the string), consisting only of characters "." and "#" and m queries. Each query is described by a pair of integers li, ri (1 ≤ li < ri ≤ n). The answer to the query li, ri is the number of such integers i (li ≤ i < ri), that si = si + 1.

Ilya the Lion wants to help his friends but is there anyone to help him? Help Ilya, solve the problem.

Input

The first line contains string s of length n (2 ≤ n ≤ 105). It is guaranteed that the given string only consists of characters "." and "#".

The next line contains integer m (1 ≤ m ≤ 105) — the number of queries. Each of the next m lines contains the description of the corresponding query. The i-th line contains integers li, ri (1 ≤ li < ri ≤ n).

Output

Print m integers — the answers to the queries in the order in which they are given in the input.

Sample test(s)
input
......
4
3 4
2 3
1 6
2 6
output
1
1
5
4
input
#..###
5
1 3
5 6
1 5
3 6
3 4
output
1
1
2
2
0

一遍扫描处理即可。


完整代码:

/*124ms,500KB*/

#include<cstdio>
#include<cstring>
const int maxn = 100010;

char str[maxn];
int count[maxn];

int main(void)
{
	gets(str);
	int len = strlen(str), m, l, r;
	for (int i = 1; i < len; ++i)
		count[i] = count[i - 1] + (str[i-1] == str[i]);
	scanf("%d", &m);
	while (m--)
	{
		scanf("%d%d", &l, &r);
		printf("%d\n", count[r - 1] - count[l - 1]);
	}
	return 0;
}


Quartus Prime器件库安装实战:从版本选择到权限避坑指南 本文详细介绍了Quartus Prime器件库的安装全流程,从版本选择、精准下载到权限设置和安装验证。重点解析了版本匹配的黄金法则、管理员权限的必要性以及安装路径的最佳实践,帮助用户避开常见陷阱,确保器件库安装一次成功。 阅读详情

相关推荐

2025年普通人转向人工智能运维(AIOps)学习建议(附最新技术实践与资源)

AIOps不仅是技术的叠加,更是运维流程的重构。建议通过“学习-实践-反馈”循环,逐步从工具使用者成长为解决方案设计者。如需完整资源链接,可访问上述推荐的优快云博客及GitHub仓库。

资深全栈架构师,乐于在 优快云 分享技术见解,与大家携手共进,共攀技术巅峰! 3096

ACM学习感悟——weekly training

Description Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam. You've got string s = s1s2... sn (n is the length of the

只玩三国的程序猿的专栏 725

数学建模--十大经典常用算法

数学建模十大算法:灰色预测,蒙特卡洛,遗传算法,模拟退火法,组合算法,神经网络,动态规划,聚类算法,类比法,概率算法,Floyd算法

qq_51533426的博客 5647

313B Ilya and Queries(前缀和)

给你一个区间,询问有多少个si=si+1 按题意做一下前缀和完事 代码: #include <bits/stdc++.h> #define int long long #define sc(a) scanf("%lld",&a) #define scc(a,b) scanf("%lld %lld",&a,&b) #define scc...

aogengbin3685的博客 170

从零到一:基于Esp32与LVGL的ST7789屏幕驱动全流程实战

本文详细介绍了基于Esp32与LVGL的ST7789屏幕驱动全流程实战,包括环境准备、驱动文件改造、硬件接口配置、LVGL集成与优化等关键步骤。通过VSCode+ESP-IDF开发环境,读者可以快速掌握SPI模式下的屏幕驱动开发,解决常见问题如颜色错乱、画面撕裂等,并实现LVGL的高效集成与性能优化。

weixin_33725722的博客 711

Yolov2 训练时anchor是如何使用的?build_target

0.简略描述 1.将真值检测框变换到特征图尺度上 2.计算以特征图每个网格中心为中心点时所有锚框与真值检测框的交并比 3.取与真值检测框交并比最大的锚框的id,及真值检测框中心所在cell的id,有此,可将真值检测框与预测结果对应起来 4.计算位置回归损失,置信度损失,分类损失 1,网络的输出 图1 yolov2 网络对于检测框位置大小的输出是: 对于1个batch网络的输出的shape为[batch_size, H*W*num_anchors, 5+num_classes], 其中: num_

机器人视觉感知 2818

cf 186 div2 B

B. Ilya and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya the Lion wants to help all his fri

hange_db的专栏 1024

用Isaac Sim复现经典案例:手把手教你写Python脚本控制机械臂抓取(附避障算法调试心得)

本文详细介绍了如何使用NVIDIA Isaac Sim仿真系统复现机械臂抓取经典案例,包括Python脚本编写、避障算法调试等关键步骤。通过URDF模型导入、关节控制逻辑实现和RMPFlow避障配置等实战演示,帮助开发者快速掌握机器人仿真技术,特别分享了官方文档未提及的实用调试技巧和性能优化策略。

weixin_30632089的博客 408

CodeForces #186(div.2) A B C

40分钟做完A,B然后把C 题看错,一直WA到结束。。。。。。。。A水题。A. Ilya and Bank Accounttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya is a very clever lion, he lives ...

weixin_30484247的博客 154

leetcode134 加油站

题目如下 在一条环路上有 N 个加油站,其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i+1 个加油站需要消耗汽油 cost[i] 升。你从其中的一个加油站出发,开始时油箱为空。 如果你可以绕环路行驶一周,则返回出发时加油站的编号,否则返回 -1。 说明: 如果题目有解,该答案即为唯一答案。 输入数组均为非空数组,且长度相同。 输...

ayang818 's blog 234

CAN 通信测试工具 canutils

概述 CAN,Controller Area Network,控制器局域网,一种高可靠性的现场总线。广泛用于汽车电子、工业控制通信。 canutils 工具包内含 5 个独立的程序:canconfig、candump、canecho、cansend、cansequence。这几个程序的功能简述如下: canconfig:用于配置 CAN 总线接口的参数,主要是波特率和模式。 candump...

一个软件工程师的技术笔记 1万+

CF:Ilya and Queries

Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam. You've got string s = s1s2... sn (n is the length of the string), con

SRC博客专栏 1108

康耐视visionpro-CogBlobTool工具详细说明

康耐视visionpro-CogBlobTool工具详细说明

视觉人机器视觉的博客 1728

B. Ilya and Queries(动态规划)Codeforces Round #186 (Div. 2)

原题链接: http://codeforces.com/contest/313/problem/B 测试样例 input … 4 3 4 2 3 1 6 2 6 output 1 1 5 4 input #…### 5 1 3 5 6 1 5 3 6 3 4 output 1 1 2 2 0 题意: 给你一个字符串sss,接下来有mmm次询问,每次询问会给定区间[l,r][l,r][l,r],你需要回答在这区间中有多少对si=si+1s_i=s_{i+1}si​=si+1​的数量,其中l≤i<r

pursuit的博客 439

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Codeforces Round #186 (Div. 2)A、B、C、D、E

A.Ilya and Bank Account Ilya得到了一个礼物,可以在删掉银行账户最后和倒数第二位的数字(账户有可能是负的),也可以不做任何处理。 //codeforces 313A //2013-05-31-13.47 #include #include using namespace std; int main() { int n; scanf("%d"

xindoo 1626

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

递推 Codeforces Round #186 (Div. 2) B. Ilya and Queries

题目传送门 1 /* 2 递推:用cnt记录前缀值,查询区间时,两个区间相减 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cmath> 7 #include <cstring> 8 using namespace ...

weixin_30877493的博客 71

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

[Codeforces Round #186 (Div. 2)] B. Ilya and Queries

B. Ilya and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya the Lion wants to help all his fri...

weixin_30724853的博客 93

Codeforces 313B - Ilya and Queries(水题)

B. Ilya and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya the Lion wants to help all his friends w...

weixin_33826268的博客 273

B. Ilya and Queries

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya the Lion wants to help all his friends with passing exams.

无知的我 1948

CF_313B_IlyaAndQueries

B. Ilya and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya the Lion wants to help all his fri

OTTFF的博客 437

CF 557A(Ilya and Diplomas-贪心)

A. Ilya and Diplomas time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Soon a school Olympiad in Informatics w

nike0good |Oier&ACMer | 熟能生巧 1597

codeforces 313B

在codeforces中 题意是要求在字符串中找到Ai==A(i+1)的个数 暴力超时 #include <iostream> #include<algorithm> #include<cmath> #include<cstdio> #include<string.h> using namespace std; int main() {...

蓝色的猴子 397

Codeforces Ilya and Queries

递推(DP) http://codeforces.com/contest/313/problem/B 题意:比较好懂,一个字符串只有.或者#字符,给你一段区间[x,y],其实y&gt;x,让你在这个区间里面统计一个数字,即这个子串,相邻两位,若s[i]=s[i+1]则计数一次,然后输出结果 这题一看,其实想到了线段树,因为原串,如果一段连续的.....则看成是一串白色的段,一段连续的####...

weixin_33915554的博客 147

HDU-1597 find the nth digit(思维)

原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1597 测试样例 Sample Input 6 1 2 3 4 5 10 Sample Output 1 1 2 1 2 4 解题思路: 我们把每个sis_isi​看成一组,由于长度呈等差数列增长,故我们可以第nnn个数字判断是在哪个组中,知道了这个我们对每个组继续进行分析,我们发现是以1~9为一个循环,所以我们只要知道这个第nnn个数字是在这个组中的哪个位置,则此题自然易解。注意思维,具体看代码。 AC

pursuit的博客 489

Ilya and Queries

Ilya and Queries               http://blog.csdn.net/zhaoxinfan/article/details/9031615

Yonggie的博客 477
上一篇: Codeforces VK Cup 2012 Qualification Round 1 /158C (字符串处理)
下一篇: POJ 2479 Maximum sum (DP&双最大子段和)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值