1006. Sign In and Sign Out (25)(-selfdone)
来源:互联网 发布:帆布包推荐 知乎 编辑:程序博客网 时间:2024/06/10 12:16
- Sign In and Sign Out (25)
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’s, you are supposed to find the ones who have unlocked and locked the door on that day.
Input Specification:
Each input file contains one test case. Each case contains the records for one day. The case starts with a positive integer M, which is the total number of records, followed by M lines, each in the format:
ID_number Sign_in_time Sign_out_time
where times are given in the format HH:MM:SS, and ID number is a string with no more than 15 characters.
Output Specification:
For each test case, output in one line the ID numbers of the persons who have unlocked and locked the door on that day. The two ID numbers must be separated by one space.
Note: It is guaranteed that the records are consistent. That is, the sign in time must be earlier than the sign out time for each person, and there are no two persons sign in or out at the same moment.
Sample Input:
3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40
Sample Output:
SC3021234 CS301133
#include<stdio.h>#include<string.h>typedef struct{ char id[20],in[20],out[20];}Record;int cmp(const void* a,const void* b){ return strcmp(a,b);}int main(){ int M; scanf("%d",&M); Record re[M]; char time[2*M][20]; int i; int cnt=0; for(i=0;i<M;i++){ char in[20],out[20]; scanf("%s %s %s",re[i].id,re[i].in,re[i].out); strcpy(time[cnt++],re[i].in); strcpy(time[cnt++],re[i].out); } qsort(time,2*M,sizeof(time[0]),cmp); char *res_in,*res_out; for(i=0;i<M;i++){ if(strcmp(re[i].in,time[0])==0) res_in=re[i].id; if(strcmp(re[i].out,time[2*M-1])==0) res_out=re[i].id; } printf("%s %s\n",res_in,res_out); return 0; }
- 1006. Sign In and Sign Out (25)(-selfdone)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- Linux下安装tar.gz类型的jdk,并配置环境变量
- 〖随记〗简单生活,开心就好~
- git添加忽略名单
- ASP.NET的Gridview控件简单使用(分页、序号、选框、全选)(附源码)
- 算法篇-8-回溯法-N皇后&最优装载&01背包
- 1006. Sign In and Sign Out (25)(-selfdone)
- Oracle触发器用法实例详解
- aop实现原理(自学)
- React开发环境配置
- zookeeper特性
- pva-faster-rcnn
- linux shell 算数运算.关系运算.布尔运算,字符串运算
- 测试fun
- 【备忘】史上最全LINUX之13套开发视频教程下载