欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1676H1.Maximum Crossings (Easy Version)
Maximum Crossings (Easy Version)
CF1676H1 · Maximum Crossings (Easy Version)
- 难度:1400
- 标签:brute force
- 链接:https://codeforces.com/problemset/problem/1676/H1
- 时间限制:1 second 内存限制:256 megabytes
- 出现位置:假期自习包/C-树状数组入门(逆序对/区间计数)
英文原题面
Statement
The only difference between the two versions is that in this version and the sum of over all test cases does not exceed . A terminal is a row of equal segments numbered to in order. There are two terminals, one above the other. You are given an array of length . For all , there should be a straight wire from some point on segment of the top terminal to some point on segment of the bottom terminal. You can't select the endpoints of a segment. For example, the following pictures show two possible wirings if and .
A crossing occurs when two wires share a point in common. In the picture above, crossings are circled in red. What is the maximum number of crossings there can be if you place the wires optimally?
Input
The first line contains an integer () — the number of test cases. The first line of each test case contains an integer () — the length of the array. The second line of each test case contains integers () — the elements of the array. The sum of across all test cases does not exceed .
Output
For each test case, output a single integer — the maximum number of crossings there can be if you place the wires optimally.
样例
样例 1
输入:
4
7
4 1 4 6 7 7 5
2
2 1
1
1
3
2 2 2
输出:
6
1
0
3
样例解释(英文原文)
The first test case is shown in the second picture in the statement. In the second test case, the only wiring possible has the two wires cross, so the answer is . In the third test case, the only wiring possible has one wire, so the answer is .
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |