ZOJ 3787 Access System
来源:互联网 发布:企业网络性能需求 编辑:程序博客网 时间:2024/05/21 18:30
For security issues, Marjar University has an access control system for each dormitory building.The system requires the students to use their personal identification cards to open the gate if they want to enter the building.
The gate will then remain unlocked for L seconds. For example L = 15, if a student came to the dormitory at 17:00:00 (in the format of HH:MM:SS) and used his card to open the gate. Any other students who come to the dormitory between [17:00:00, 17:00:15) can enter the building without authentication. If there is another student comes to the dorm at 17:00:15 or later, he must take out his card to unlock the gate again.
There are N students need to enter the dormitory. You are given the time they come to the gate. These lazy students will not use their cards unless necessary. Please find out the students who need to do so.
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains two integers N (1 <= N <= 20000) andL (1 <= L <= 3600). The next N lines, each line is a unique time between [00:00:00, 24:00:00) on the same day.
Output
For each test case, output two lines. The first line is the number of students who need to use the card to open the gate. The second line the the index (1-based) of these students in ascending order, separated by a space.
Sample Input
32 112:30:0012:30:015 1517:00:0017:00:1517:00:0617:01:0017:00:143 512:00:0912:00:0512:00:00
Sample Output
21 231 2 422 3
#include <stdio.h>#include <algorithm>using namespace std;struct aa{ int num; int h,m,s; int sum;}a[20005];bool cmp(aa b,aa c){ return b.sum<c.sum;}int main(){ int cas,ans[20005],l,n,t,tt; scanf("%d",&cas); while(cas--) { scanf("%d %d",&n,&t); for(int i=1;i<=n;i++) { scanf("%d:%d:%d",&a[i].h,&a[i].m,&a[i].s); a[i].sum=a[i].h*3600+a[i].m*60+a[i].s; a[i].num=i; } sort(a+1,a+n+1,cmp); l=0; for(int i=1;i<=n;i++) { if(i==1) { ans[l++]=a[i].num; tt=a[i].sum; } else { if(tt+t<=a[i].sum) { ans[l++]=a[i].num; tt=a[i].sum; } } } printf("%d\n",l); sort(ans,ans+l); for(int i=0;i<l-1;i++) printf("%d ",ans[i]); printf("%d\n",ans[l-1]); } return 0;}
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- zoj 3787 Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System 模拟
- ZOJ 3787Access System(排序)
- ZOJ Access System
- ZOJ-3787-Access System【11th浙江省赛】
- Access System
- Access System
- Access System
- zoj 1088 System Overload
- zoj-1088-System Overload
- zoj 1409 Communication System
- opengl es 的EGL使用
- java反射机制的使用
- 如何解决blur事件和click事件冲突问题?
- js金额计算精度缺失解决方案(只此一家,错过后悔)
- Android实战简易教程-第五十五枪(窃听风云之电话录音上传)
- ZOJ 3787 Access System
- RMI 相关知识
- C#枚举 方法应用示例
- LeapFTP 显示服务器端文件名乱码问题处理
- 用libjson-glib处理json数据
- Android之ScrollView嵌套ListView显示不全的问题
- 八种常用电容器的结构和特点
- Hadoop2.6.0 单节点安装
- ls命令--linux