A1217 | [COCI-2010_2011-olympiad]#5 TELKA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Recently there was a population census in Mirko's country. Along with numerous other data that was being collected, very important part was the data about television ratings.
Each of the N citizens provided two timestamps in the following format:
HH:MM:SS – HH:MM:SS The first timestamp describes the time of the day when citizen started watching television, and the second one the time when that citizen stopped watching. Citizen also watched television during the first and the last second of the given interval. Note that it is possible to start watching before midnight, eg., at 23:45:30, and not finish until the next day, eg., at 01:15:0
0.
After all the data has been collected, statisticians are gathered in order to analyse it.
We define the popularity of some second as the total number of citizens that were watching television during that second. Furthermore, the popularity of the given time interval is defined as the sum of popularities of seconds contained within that interval, divided by the length of the interval.
Calculate the popularities of the Q given time intervals that are of special interest to the statisticians.
Each of the N citizens provided two timestamps in the following format:
HH:MM:SS – HH:MM:SS The first timestamp describes the time of the day when citizen started watching television, and the second one the time when that citizen stopped watching. Citizen also watched television during the first and the last second of the given interval. Note that it is possible to start watching before midnight, eg., at 23:45:30, and not finish until the next day, eg., at 01:15:0
0.
After all the data has been collected, statisticians are gathered in order to analyse it.
We define the popularity of some second as the total number of citizens that were watching television during that second. Furthermore, the popularity of the given time interval is defined as the sum of popularities of seconds contained within that interval, divided by the length of the interval.
Calculate the popularities of the Q given time intervals that are of special interest to the statisticians.
输入格式
The first line of input contains integer N (N ≤ 100 000), the number of citizens.
The following N lines each contain two timestamps given by that citizen, in the format described above (0 ≤ HH ≤ 23, 0 ≤ MM ≤ 59, 0 ≤ SS ≤ 59).
In the following line there is an integer Q (Q ≤ 100 000), describing the number of time intervals that statisticians are interested in.
The following Q lines contain time intervals in the same format as above.
The following N lines each contain two timestamps given by that citizen, in the format described above (0 ≤ HH ≤ 23, 0 ≤ MM ≤ 59, 0 ≤ SS ≤ 59).
In the following line there is an integer Q (Q ≤ 100 000), describing the number of time intervals that statisticians are interested in.
The following Q lines contain time intervals in the same format as above.
输出格式
For each of the Q given intervals, output it's popularity in seperate line.
Solution will be accepted if apsolute or relative error is at most 10^-
6.
Solution will be accepted if apsolute or relative error is at most 10^-
6.
输入输出样例
输入 #1
5 00:00:00 - 00:00:01 00:00:01 - 00:00:03 00:00:00 - 00:00:02 00:00:05 - 00:00:09 00:00:06 - 00:00:06 5 00:00:00 - 00:00:03 00:00:07 - 00:00:09 00:00:06 - 00:00:06 00:00:05 - 00:00:09 00:00:00 - 00:00:09
输出 #1
2.0000000000 1.0000000000 2.0000000000 1.2000000000 1.4000000000
输入 #2
3 00:00:00 - 10:00:00 10:00:00 - 00:00:00 01:01:01 - 02:02:02 4 00:00:00 - 23:59:59 23:59:59 - 23:59:58 23:59:59 - 23:59:59 08:34:43 - 12:22:17
输出 #2
1.0424074074 1.0424074074 1.0000000000 1.0000732332
In test cases worth a total of 25% points, N ≤ 500 and Q ≤ 500 will hold.
In test cases worth a total of 25% points, N ≤ 500 and Q ≤ 100 000 will hold.
In test cases worth a total of 25% points, N ≤ 100 000 and Q ≤ 500 will hold.
In test cases worth a total of 25% points, N ≤ 500 and Q ≤ 100 000 will hold.
In test cases worth a total of 25% points, N ≤ 100 000 and Q ≤ 500 will hold.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted