欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
5121.Rorororobot
Rorororobot
CF1709D · Rorororobot
- 难度:1700
- 标签:binary search、data structures、greedy、math
- 链接:https://codeforces.com/problemset/problem/1709/D
- 时间限制:2 seconds 内存限制:256 megabytes
- 出现位置:Day05-二分答案-ST表-RMQ
英文原题面
Statement
There is a grid, consisting of rows and columns. The rows are numbered from to from bottom to top. The columns are numbered from to from left to right. The -th column has the bottom cells blocked (the cells in rows ), the remaining cells are unblocked. A robot is travelling across this grid. You can send it commands — move up, right, down or left. If a robot attempts to move into a blocked cell or outside the grid, it explodes. However, the robot is broken — it executes each received command times. So if you tell it to move up, for example, it will move up times ( cells). You can't send it commands while the robot executes the current one. You are asked queries about the robot. Each query has a start cell, a finish cell and a value . Can you send the robot an arbitrary number of commands (possibly, zero) so that it reaches the finish cell from the start cell, given that it executes each command times? The robot must stop in the finish cell. If it visits the finish cell while still executing commands, it doesn't count.
Input
The first line contains two integers and (; ) — the number of rows and columns of the grid. The second line contains integers () — the number of blocked cells on the bottom of the -th column. The third line contains a single integer () — the number of queries. Each of the next lines contain five integers and (; ; ; ; ) — the row and the column of the start cell, the row and the column of the finish cell and the number of times each your command is executed. The start and the finish cell of each query are unblocked.
Output
For each query, print "YES" if you can send the robot an arbitrary number of commands (possibly, zero) so that it reaches the finish cell from the start cell, given that it executes each command times. Otherwise, print "NO".
样例
样例 1
输入:
11 10
9 0 0 10 3 4 8 11 10 8
6
1 2 1 3 1
1 2 1 3 2
4 3 4 5 2
5 3 11 5 3
5 3 11 5 2
11 9 9 10 1
输出:
YES
NO
NO
NO
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |