4-13-L

L - 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
晚上没A出来,挺郁闷的,补题的时候发现其实自己压根就没用正确的题意,只是听了队友的理解,但是错的理解,就当是个教训,以后记住这点不懂得题,坚决不码,浪费队友的时间,也是无用功。
超水的题,贴上吧:
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node 
{
	int sum,p;
}s[100000];
bool cmp(node a,node b)
{
	return a.sum<b.sum;
}
int main() 
{
	int m,n,l,i,j,cc,a,b,c,p[100000],nn;
	scanf("%d",&nn);
	while(nn--)
		{
		cc=1;
	     scanf("%d%d",&n,&l);
		for(i=0;i<n;i++)
		{
			scanf("%d:%d:%d",&a,&b,&c);
			s[i].sum=a*3600+b*60+c;
			s[i].p=i+1;
		}
		sort(s,s+n,cmp);
		m=s[0].sum;
		for(j=1;j<n;j++)
		if(s[j].sum-m>=l)
		{
		  p[cc++]=s[j].p;
		  m=s[j].sum;
		}
		p[0]=s[0].p;
		sort(p,p+cc);
		printf("%d\n",cc);
		for(i=0;i<cc-1;i++)
		printf("%d ",p[i]);
		printf("%d\n",p[cc-1]);
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值