Access System

 Access System
Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu

Description

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

3
2 1
12:30:00
12:30:01
5 15
17:00:00
17:00:15
17:00:06
17:01:00
17:00:14
3 5
12:00:09
12:00:05
12:00:00

Sample Output

2
1 2
3
1 2 4
2
2 3


#include <iostream>
#include<cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
struct node
{
    int h,m,s;
    int i;
    int time;
}st[20005];
int cmp(node a,node b)
{
    return a.time<b.time;
}
int main()
{
    int t;
    cin>>t;
    char d,k;
    while(t--){
        int n,l;
        cin>>n>>l;
        for(int i=1;i<=n;i++){
            scanf("%d%c%d%c%d",&st[i].h,&d,&st[i].m,&k,&st[i].s);
            st[i].i=i;
            st[i].time=(st[i].h-st[1].h)*3600+(st[i].m-st[1].m)*60+(st[i].s-st[1].s);
        }
        st[1].time=0;
        sort(st+1,st+n+1,cmp);
        int count=1;
        int a[20005];
        int flag=1,p=1;
        a[0]=st[1].i;
        for(int i=2;i<=n;i++){
            if(st[i].time>=st[flag].time+l){
                flag=i;
                count++;
                a[p++]=st[i].i;
            }
        }
        cout<<count<<endl;
        sort(a,a+p);
        for(int i=0;i<p;i++){
            if(i==0)        cout<<a[0];
            else            cout<<" "<<a[i];
        }
        cout<<endl;
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黎轩栀海

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值