ZOJ Problem Set - 3787
2014-04-12 22:52
344 查看
Time Limit: 2 SecondsMemory Limit: 65536 KBFor 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 exampleL = 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 isanother 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 integerT 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 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<string>#include<list>#include<cstdio>#include<cstdlib>#include<cstring>#include<cstring>int s[90000]={0};int sz[90000]={0};using namespace std;int comp(const void *a,const void *b){return *(int *)a-*(int *)b;}int main(){int n;scanf("%d",&n);while(n--){int a,b,d,e,f,i,z,cnt=0,j=0;memset(s,0,sizeof(s));memset(sz,0,sizeof(sz));scanf("%d %d",&a,&b);for(i=0;i<a;i++){scanf("%d:%d:%d",&d,&e,&f);s[d*3600+e*60+f]=i+1;}for(i=0;i<90000;i++){if(s[i]){cnt++;sz[j++]=s[i];i+=b-1;}}qsort(sz,j,sizeof(int),comp);printf("%d\n",cnt);for(i=0;i<j-1;i++)printf("%d ",sz[i]);printf("%d\n",sz[i]);}return 0;}[/code]
相关文章推荐
- ZOJ Problem Set - 2186 Keep on Truckin'
- ZOJ Problem Set - 1008
- ZOJ Problem Set - 1009
- ZOJ Problem Set - 3777
- ZOJ Problem Set - 1655
- ZOJ Problem Set - 1986 Bridging Signals
- ZOJ Problem Set - 1456
- ZOJ Problem Set - 2818
- ZOJ Problem Set - 3869
- ZOJ Problem Set - 1240 IBM Minus One
- ZOJ Problem Set - 3326 An Awful Problem(模拟题,待改正)
- ZOJ Problem Set - 1004
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
- ZOJ Problem Set - 1003 Crashing Balloon
- ZOJ Problem Set - 1005 Jugs
- ZOJ Problem Set - 2110 Tempter of the Bone
- ZOJ Problem Set - 3827Information Entropy
- ZOJ Problem Set - 1115
- ZOJ Problem Set–1241 Geometry Made Simple
- ZOJ Problem Set–1489 2^x mod n = 1