欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2005B1.The Strict Teacher (Easy Version)
The Strict Teacher (Easy Version)
This is the easy version of the problem. The only differences between the two versions are the constraints on and . In this version, and . You can make hacks only if both versions of the problem are solved.
Narek and Tsovak were busy preparing this round, so they have not managed to do their homework and decided to steal David's homework. Their strict teacher noticed that David has no homework and now wants to punish him. She hires other teachers to help her catch David. And now teachers together are chasing him. Luckily, the classroom is big, so David has many places to hide.
The classroom can be represented as a one-dimensional line with cells from to , inclusive.
At the start, all teachers and David are in distinct cells. Then they make moves. During each move
- David goes to an adjacent cell or stays at the current one.
- Then, each of the teachers simultaneously goes to an adjacent cell or stays at the current one.
This continues until David is caught. David is caught if any of the teachers (possibly more than one) is located in the same cell as David. Everyone sees others' moves, so they all act optimally.
Your task is to find how many moves it will take for the teachers to catch David if they all act optimally.
Acting optimally means the student makes his moves in a way that maximizes the number of moves the teachers need to catch him; and the teachers coordinate with each other to make their moves in a way that minimizes the number of moves they need to catch the student.
Also, as Narek and Tsovak think this task is easy, they decided to give you queries on David's position. Note: this is the easy version, and you are given only one query.
Input
In the first line of the input, you are given a single integer () — the number of test cases. The description of each test case follows.
In the first line of each test case, you are given three integers , , and (, , ) — the number of cells on the line, the number of teachers, and the number of queries.
In the second line of each test case, you are given distinct integers () — the cell numbers of the teachers.
In the third line of each test case, you are given integers () — David's cell number for every query.
It is guaranteed that for any , such that and , .
Output
For each test case, output lines, the -th of them containing the answer of the -th query.
Note
In the first example, the student can just stay at cell . The teacher, initially located in cell , can reach cell in one move. Therefore, the answer is .
In the second example, the student should just stay at cell . The teacher, initially located in cell , can reach cell in two moves. Therefore, the answer is .
Samples
3
10 2 1
1 4
2
8 2 1
3 6
1
8 2 1
3 6
8
1
2
2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |