欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2064B.Variety is Discouraged
Variety is Discouraged
Define the score of an arbitrary array to be the length of minus the number of distinct elements in . For example:
- The score of is , as it has length and only distinct elements (, , ).
- The score of is , as it has length and only distinct element ().
- The empty array has a score of .
You have an array . You need to remove some non-empty contiguous subarray from at most once.
More formally, you can do the following at most once:
- pick two integers , where , and
- delete the contiguous subarray from (that is, replace with ).
Output an operation such that the score of is maximum; if there are multiple answers, output one that minimises the final length of after the operation. If there are still multiple answers, you may output any of them.
Input
The first line contains an integer () — the number of testcases.
The first line of each testcase contains an integer () — the length of the array .
The second line of each testcase contains integers ().
The sum of across all testcases does not exceed .
Output
For each testcase, if you wish to not make a move, output .
Otherwise, output two integers and (), representing the left and right bound of the removed subarray.
The removed subarray should be chosen such that the score is maximized, and over all such answers choose any of them that minimises the final length of the array.
Note
In the first testcase, we have two options:
- do nothing: the score of is .
- remove the subarray with , : we remove the only element, and we get an empty array with score .
Therefore, the maximum score possible is . However, since we need to additionally minimise the final length of the array, we must output the second option with . Note that the first option of doing nothing is incorrect, since it has a longer final length.
In the second testcase, no subarray is selected, so after which is still . This has length and distinct element, so it has a score of . This can be proven to be a shortest array which maximises the score.
In the third testcase, the subarray selected is , after which becomes . This has length and distinct element, so it has a score of . This can be proven to be a shortest array which maximises the score.
Samples
3
1
1
5
1 1 1 1 1
4
2 1 3 2
1 1
0
2 3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |