欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1332A.Exercising Walk
Exercising Walk
Alice has a cute cat. To keep her cat fit, Alice wants to design an exercising walk for her cat!
Initially, Alice's cat is located in a cell of an infinite grid. According to Alice's theory, cat needs to move:
- exactly steps left: from to ;
- exactly steps right: from to ;
- exactly steps down: from to ;
- exactly steps up: from to .
Note that the moves can be performed in an arbitrary order. For example, if the cat has to move step left, steps right and steps down, then the walk right, down, left, right, right, down is valid.
Alice, however, is worrying that her cat might get lost if it moves far away from her. So she hopes that her cat is always in the area , i.e. for every cat's position of a walk and holds.
Also, note that the cat can visit the same cell multiple times.
Can you help Alice find out if there exists a walk satisfying her wishes?
Formally, the walk should contain exactly unit moves ( to the left, to the right, to the down, to the up). Alice can do the moves in any order. Her current position should always satisfy the constraints: , . The staring point is .
You are required to answer test cases independently.
Input
The first line contains a single integer () — the number of testcases.
The first line of each test case contains four integers , , , (, ).
The second line of the test case contains six integers , , , , , (, ).
Output
For each test case, output "YES" in a separate line, if there exists a walk satisfying her wishes. Otherwise, output "NO" in a separate line.
You can print each letter in any case (upper or lower).
Note
In the first test case, one valid exercising walk is $$(0,0)\rightarrow (-1,0) \rightarrow (-2,0)\rightarrow (-2,1) \rightarrow (-2,2)\rightarrow (-1,2)\rightarrow(0,2)\rightarrow (0,1)\rightarrow (0,0) \rightarrow (-1,0)$$
Samples
6
3 2 2 2
0 0 -2 -2 2 2
3 1 4 1
0 0 -1 -1 1 1
1 1 1 1
1 1 1 1 1 1
0 0 0 1
0 0 0 0 0 1
5 1 1 1
0 0 -100 -100 0 100
1 1 5 1
0 0 -100 -100 100 0
Yes
No
No
Yes
Yes
Yes
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |