• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

ZOJ Access System

mysql 搞代码 4年前 (2022-01-09) 15次浏览 已收录 0个评论

Time Limit: 2 Seconds Memory Limit: 65536 KB 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 th

Time Limit: 2 Seconds Memory Limit: 65536 KB


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 本文来源gao@!dai!ma.com搞$$代^@码网*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:14<span>3 512:00:0912:00:0512:00:00</span>

Sample Output

21 231 2 4<span>22 3</span>
<pre class="prettyprint linenums">#include#include#includeusing namespace std;typedef struct nnn{    int s,i;}Time;int cmp(Time a,Time b){    return a.s<b.s;}int main(){    Time student[20005],node;    int t,n,L,sum,c,loc[20005],h,m;    scanf("%d",&t);    while(t--)    {        scanf("%d%d",&n,&L);        sum=0;        for(int i=0;i<n;i++)        {            scanf("%d:%d:%d",&h,&m,&student[i].s);            student[i].s+=h*3600+m*60;            student[i].i=i+1;        }        sort(student,student+n,cmp);        if(n) {            sum=1; loc[sum]=student[0].i;            node.s=student[0].s+L;        }        for(int i=1;i<n;i++)        if(node.s<=student[i].s)        {            sum++; loc[sum]=student[i].i;            node.s=student[i].s+L;        }        sort(loc+1,loc+sum+1);        printf("%d\n",sum);        if(sum) printf("%d",loc[1]);        for(int i=2;i<=sum;i++)        printf(" %d",loc[i]);        printf("\n");    }}

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:ZOJ Access System
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址