欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1623B.Game on Ranges
Game on Ranges
Alice and Bob play the following game. Alice has a set of disjoint ranges of integers, initially containing only one range . In one turn, Alice picks a range from the set and asks Bob to pick a number in the range. Bob chooses a number (). Then Alice removes from and puts into the set the range (if ) and the range (if ). The game ends when the set is empty. We can show that the number of turns in each game is exactly .
After playing the game, Alice remembers all the ranges she picked from the set , but Bob does not remember any of the numbers that he picked. But Bob is smart, and he knows he can find out his numbers from Alice's ranges, and so he asks you for help with your programming skill.
Given the list of ranges that Alice has picked (), for each range, help Bob find the number that Bob has picked.
We can show that there is always a unique way for Bob to choose his number for a list of valid ranges picked by Alice.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains a single integer ().
Each of the next lines contains two integers and (), denoting the range that Alice picked at some point.
Note that the ranges are given in no particular order.
It is guaranteed that the sum of over all test cases does not exceed , and the ranges for each test case are from a valid game.
Output
For each test case print lines. Each line should contain three integers , , and , denoting that for Alice's range Bob picked the number .
You can print the lines in any order. We can show that the answer is unique.
It is not required to print a new line after each test case. The new lines in the output of the example are for readability only.
Note
In the first test case, there is only 1 range . There was only one range for Alice to pick, and there was only one number for Bob to pick.
In the second test case, . Initially, the set contains only one range .
- Alice picked the range . Bob picked the number . Then Alice put the range back to the set, which after this turn is the only range in the set.
- Alice picked the range . Bob picked the number . Then Alice put the range back to the set.
- Alice picked the range . Bob picked the number . The game ended.
In the fourth test case, the game was played with . Initially, the set contains only one range . The game's turn is described in the following table.
| Game turn | Alice's picked range | Bob's picked number | The range set after |
|---|---|---|---|
| Before the game start | |||
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | (empty set) | ||
Samples
4
1
1 1
3
1 3
2 3
2 2
6
1 1
3 5
4 4
3 6
4 5
1 6
5
1 5
1 2
4 5
2 2
4 4
1 1 1
1 3 1
2 2 2
2 3 3
1 1 1
3 5 3
4 4 4
3 6 6
4 5 5
1 6 2
1 5 3
1 2 1
4 5 5
2 2 2
4 4 4
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |