ZOJ3787 Access System
来源:互联网 发布:jetbrains golang 编辑:程序博客网 时间:2024/06/06 08:28
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) and L (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
转换成60进制就可以轻松排序 了
#include<stdio.h>#include<algorithm>using namespace std;struct ss{ int ti,num;}s[20004];bool cmp(ss a,ss b){ if(a.ti==b.ti) return a.num<b.num; return a.ti<b.ti;}int t[20004];int main(){ int cas,n,l,i,h,m,ss,flag; scanf("%d",&cas); while(cas--) { scanf("%d%d",&n,&l); for(i=0;i<n;i++) { scanf("%d:%d:%d",&h,&m,&ss); s[i].ti=h*3600+m*60+ss; s[i].num=i+1; } sort(s,s+n,cmp); int ans=1; flag=s[0].ti; t[0]=s[0].num; for(i=1;i<n;i++) { if(s[i].ti-flag>=l) { t[ans++]=s[i].num; flag=s[i].ti; } } sort(t,t+ans); printf("%d\n",ans); for(i=0;i<ans-1;i++) { printf("%d ",t[i]); } printf("%d\n",t[i]); } return 0;}
- ZOJ3787:Access System
- ZOJ3787 Access System
- ZOJ3787-Access System
- Access System
- Access System
- Access System
- ZOJ Access System
- ZOJ 3787 Access System
- L、Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- zoj 3787 Access System
- L.Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- ZOJ 3787 Access System
- Terminal Access Controller Access-Control System
- EXCEL学习笔记
- android:shrinkColumns的用法
- android SharedPreferences介绍(一)
- Unity3D自带例子AngryBots的分析
- 周杰伦澳洲过安检双节棍被扣 被质疑挟大批武器入境
- ZOJ3787 Access System
- C语言中函数参数入栈的顺序
- 利用 test 指令的測試功能
- ZOJ3785 What day is that day?(找循环节)
- LeetCode – Evaluate Reverse Polish Notation
- 幸福就是和相爱的人过一辈子
- windows adb不识别(VID PID更改)
- 每日自动签到签退的程序
- 谁能守候你一生