#abc207c. C - Many Segments
C - Many Segments
Score : points
问题描述
给定个区间,编号为从1到,它们分别为:
- 如果,则第个区间为;
- 如果,则第个区间为;
- 如果,则第个区间为;
- 如果,则第个区间为。
请问有多少对整数满足,使得第个区间和第个区间相交?
什么是?
- 闭区间是一个包含所有实数的区间,满足。
- 半开区间是一个包含所有实数的区间,满足。
- 半开区间是一个包含所有实数的区间,满足。
- 开区间是一个包含所有实数的区间,满足。
简单来说,方括号[]
表示端点被包含在内,圆括号()
表示端点被排除在外。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given intervals numbered through , that are as follows:
- if , Interval is ;
- if , Interval is ;
- if , Interval is ;
- if , Interval is .
How many pairs of integers satisfying are there such that Interval and Interval intersect?
What are ?
- A closed interval is an interval consisting of all real numbers such that .
- A half-open interval is an interval consisting of all real numbers such that .
- A half-open interval is an interval consisting of all real numbers such that .
- A open interval is an interval consisting of all real numbers such that .
Roughly speaking, square brackets mean the endpoint is included, and curly brackets mean the endpoint is excluded.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of pairs of integers such that Interval and Interval intersect.
Sample Input 1
3
1 1 2
2 2 3
3 2 4
Sample Output 1
2
As defined in the Problem Statement, Interval is , Interval is , and Interval is .
There are two pairs of integers such that Interval and Interval intersect: and . For the first pair, the intersection is , and for the second pair, the intersection is .
Sample Input 2
19
4 210068409 221208102
4 16698200 910945203
4 76268400 259148323
4 370943597 566244098
1 428897569 509621647
4 250946752 823720939
1 642505376 868415584
2 619091266 868230936
2 306543999 654038915
4 486033777 715789416
1 527225177 583184546
2 885292456 900938599
3 264004185 486613484
2 345310564 818091848
1 152544274 521564293
4 13819154 555218434
3 507364086 545932412
4 797872271 935850549
2 415488246 685203817
Sample Output 2
102
update @ 2024/3/10 09:20:37