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
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.
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 L (1 L N lines, each line is a unique time between [00:00:00, 24:00:00) on the same day.
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.
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 <span>3 5 12:00:09 12:00:05 12:00:00</span>
2 1 2 3 1 2 4 <span>2 2 3 </span>
<pre class="brush:php;toolbar:false;">#include<stdio.h>
#include<iostream>
#include<algorithm>
using 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");
}
}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
C++高性能并发应用_C++如何开发性能关键应用
Java AI集成Deep Java Library_Java怎么集成AI模型部署
Golang后端API开发_Golang如何高效开发后端和API
Python异步并发改进_Python异步编程有哪些新改进
C++系统编程内存管理_C++系统编程怎么与Rust竞争内存安全
Java GraalVM原生镜像构建_Java怎么用GraalVM构建高效原生镜像
Python FastAPI异步API开发_Python怎么用FastAPI构建异步API
C++现代C++20/23/26特性_现代C++有哪些新标准特性如modules和coroutines
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号