没有合适的资源?快使用搜索试试~ 我知道了~
TOJ习题:《数据结构》-邓俊辉-清华大学1
需积分: 0 0 下载量 122 浏览量
2022-08-08
18:20:27
上传
评论
收藏 391KB DOCX 举报
温馨提示
试读
31页
TOJ习题:《数据结构》-邓俊辉-清华大学1
资源详情
资源评论
资源推荐
A1.1.范围查询(Range)
Descriptioin
Let S be a set of n integral points on the x-axis. For each given interval [a, b], you are
asked to count the points lying inside.
Input
The first line contains two integers: n (size of S) and m (the number of queries).
The second line enumerates all the n points in S.
Each of the following m lines consists of two integers a and b and defines an query
interval [a, b].
Output
The number of points in S lying inside each of the m query intervals.
Example
Input
5 2
1 3 7 9 11
4 6
7 12
Output
0
3
Restrictions
0 <= n, m <= 5 * 10^5
For each query interval [a, b], it is guaranteed that a <= b.
Points in S are distinct from each other.
Coordinates of each point as well as the query interval boundaries a and b are
non-negative integers not greater than 10^7.
Time: 2 sec
Memory: 256 MB
描述
数轴上有 n 个点,对于任一闭区间 [a, b],试计算落在其内的点数。
输入
第一行包括两个整数:点的总数 n,查询的次数 m。
第二行包含 n 个数,为各个点的坐标。
以下 m 行,各包含两个整数:查询区间的左、右边界 a 和 b。
输出
对每次查询,输出落在闭区间[a, b]内点的个数。
样例
见英文题面
限制
0 ≤ n, m ≤ 5×10
5
对于每次查询的区间[a, b],都有 a ≤ b
各点的坐标互异
各点的坐标、查询区间的边界 a、b,均为不超过 10^7 的非负整数
时间:2 sec
内存:256 MB
A1.2.祖玛(Zuma)
Description
Let's play the game Zuma!
There are a sequence of beads on a track at the right beginning. All the beads are
colored but no three adjacent ones are allowed to be with a same color. You can then
insert beads one by one into the sequence. Once three (or more) beads with a same
color become adjacent due to an insertion, they will vanish immediately.
Note that it is possible for such a case to happen for more than once for a single
insertion. You can't insert the next bead until all the eliminations have been done.
Given both the initial sequence and the insertion series, you are now asked by the fans
to provide a playback tool for replaying their games. In other words, the sequence of
beads after all possible eliminations as a result of each insertion should be calculated.
Input
The first line gives the initial bead sequence. Namely, it is a string of capital letters from
'A' to 'Z', where different letters correspond to beads with different colors.
The second line just consists of a single interger n, i.e., the number of insertions.
The following n lines tell all the insertions in turn. Each contains an integer k and a
capital letter Σ, giving the rank and the color of the next bead to be inserted respectively.
Specifically, k ranges from 0 to m when there are currently m beads on the track.
Output
n lines of capital letters, i.e., the evolutionary history of the bead sequence.
Specially, "-" stands for an empty sequence.
Example
Input
ACCBA
5
1 B
0 A
2 B
4 C
0 A
Output
ABCCBA
AABCCBA
AABBCCBA
-
A
Restrictions
0 <= n <= 10^4
0 <= length of the initial sequence <= 10^4
Time: 2 sec
Memory: 256 MB
Hints
List
描述
祖玛是一款曾经风靡全球的游戏,其玩法是:在一条轨道上初始排列着若干个彩色珠子,其
中任意三个相邻的珠子不会完全同色。此后,你可以发射珠子到轨道上并加入原有序列中。
一旦有三个或更多同色的珠子变成相邻,它们就会立即消失。这类消除现象可能会连锁式发
生,其间你将暂时不能发射珠子。
开发商最近准备为玩家写一个游戏过程的回放工具。他们已经在游戏内完成了过程记录的功
能,而回放功能的实现则委托你来完成。
游戏过程的记录中,首先是轨道上初始的珠子序列,然后是玩家接下来所做的一系列操作。
你的任务是,在各次操作之后及时计算出新的珠子序列。
输入
第一行是一个由大写字母'A'~'Z'组成的字符串,表示轨道上初始的珠子序列,不同的字母表
示不同的颜色。
第二行是一个数字 n,表示整个回放过程共有 n 次操作。
接下来的 n 行依次对应于各次操作。每次操作由一个数字 k 和一个大写字母 Σ 描述,以空
格分隔。其中,Σ 为新珠子的颜色。若插入前共有 m 颗珠子,则 k ∈ [0, m]表示新珠子嵌
入之后(尚未发生消除之前)在轨道上的位序。
输出
输出共 n 行,依次给出各次操作(及可能随即发生的消除现象)之后轨道上的珠子序列。
如果轨道上已没有珠子,则以“-”表示。
样例
见英文题面
限制
0 ≤ n ≤ 10^4
0 ≤ 初始珠子数量 ≤ 10^4
时间:2 sec
剩余30页未读,继续阅读
查理捡钢镚
- 粉丝: 17
- 资源: 318
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
- 基于单片机的风力发电机转速控制源码
- 基于C++实现的风力发电气动平衡监测系统+源代码+测量数据(高分课程设计)
- 毕业设计- 基于STM32F103C8T6 单片机,物联网技术的太阳能发电装置+源代码+文档说明+架构图+界面截图
- 基于 LSTM(长短期记忆)(即改进的循环神经网络)预测风力发电厂中风力涡轮机产生的功率+源代码+文档说明
- 基于stm32f103+空心杯电机+oled按键+运动算法
- 《CKA/CKAD应试指南/从docker到kubernetes 完全攻略》学习笔记 第1章docker基础(1.1-1.4)
- 基于python实现的水下压缩空气储能互补系统建模仿真与经济效益分析+源代码+论文
- 华中科技大学-自然语言处理实验,Bi-LSTM+CRF的中文分词框架,并且利用基于深度学习的方法进行中文命名实体识别++源码报告
- 基于动态罚函数的铁路车流分配与径路优化模型python源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0