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;
}


Pydoll浏览器自动化框架教程 让浏览器自动化回归本质。不再纠缠驱动兼容、不再手动处理验证码、不再因为请求和 UI 分裂而头疼。如果你经常做 Web 自动化、爬虫或者测试,不妨试试 Pydoll。也别忘了给项目点个 ⭐,让作者知道有人喜欢这个工具。👉GitHub 地址。 阅读详情

相关推荐

Truncated SVD for faster dection

Truncated SVD方法最先被提出在《Fast R-CNN》论文中,用于降低全连接层的运算量,提升模型的速度。在卷积神经网络的分类任务中,FC层的运算速度远远大于CONV层,而在Fast R-CNN的目标检测任务中,大多数的运算时间发生在FC 的运算中,是因为针对每张输入图片,只进行一次卷积操作,而要对生成的Region Proposal,大致两千个,进行全连接操作进行分类与Bounding...

weixin_35747666的博客 1535

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

论文理解【LLM-OR】—— 【PaMOP】Guiding Large Language Models in Modeling Optimization Problem

针对 LLM 求解运筹优化任务,PaMOP 通过约束划分树分离子问题,实现复杂优化问题的分块建模,并结合求解器反馈与反向翻译一致性检查迭代纠错,降低子任务复杂度,提升可执行率与建模准确性。

佚失的诗篇 1007

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

Geant4 案例分析(一): B1

本文是对Geant4 B1的案例分析,其中特定的功能不做介绍,而注重于各个文件的主要功能,以及它们组织的方式。

m0_51809467的博客 1583

历年CSP-J(NOIP普及组)考点分析与分类汇总(纯干货)

noip/csp-j历年真题考点分类

weixin_42358969的博客 1万+

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

EDSR图像超分辨程序复现(踩坑及解决记录)

EDSR图像超分辨程序复现(踩坑及解决记录)

Sunny_Coder的博客 3642

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

SAP 创建PO时提示“不能确定任何组件”

SAP 创建委外加工的PO时提示“不能确定任何组件” 而如果BOM已经创建了,但还是提示该错误保存。 解决办法:1. BOM selection 未配置好; 2. 由于Purchasing prosessing time的设置,如果PO中的delivery time - Purchasing prosessing time是过去的日期,那么会找不到BOM,BOM的有效期需早 于PO审批的有效期。 3. BOM未...

willieyuan的博客 6122

WorkBuddy CAD 审图救命课:约束、单位、尺寸链一次查清,打样前拦住返工

最危险的 CAD 文件不是打不开,而是看起来完整却混用了毫米与英寸、草图欠约束、关键尺寸没有来源。审图任务必须先列规则,再输出问题位置。 本课不会用“AI 一键完成”制造错觉,而是把 WorkBuddy、FreeCAD 0.21.2、OpenCascade 7.7 与人工审阅组成一条可复现链路。你会从“一份模拟 STEP 文件、参数表、装配基准与审图标准”出发,得到“单位报告、约束清单、尺寸链风险表与人工复核标记”,并学会用真实命令、错误信号和停止条件判断成果能不能进入下一阶段。

yueyeguzhuo的专栏 266

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

springboot&mybatis中数组和字符串数据类型的转换

/前端数组字段//数据库中字段/*与前端交互时使用的get/set*/System.out.println("接收前端数据");/*与前端交互时使用的get/set*//*与数据库交互时使用的get/set*/System.out.println("从数据库中读取数据");/*与数据库交互时使用的get/set*/

l_q_l的专栏 2475

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

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

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

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

递推 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

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

[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

Codeforces 313B : Ilya and Queries

大兄弟, 非得用这种弱智提给自己找存在感吗? (不用memset不能确保数组的初值全部为0) #include #include #include #include #define maxn 100010 using namespace std; int main() { char s[maxn]; int dp[maxn]; memset(dp

悟已往之不谏,知来者之可追 1096
上一篇: 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、付费专栏及课程。

余额充值