到、签离记录,请根据记录找出当天开门和关门的人。
每天的记录在第一行给出记录的条目数M ( > 0 ),下面是M行,每行的格式为
证件号码 签到时间 签离时间
其中时间按“小时:分钟:秒钟”(各占2位)给出,证件号码是长度不超过15的字符串。
注意:在裁判的标准测试输入中,所有记录保证完整,每个人的签到时间在签离时间之前,
且没有多人同时签到或者签离的情况。
3 1 ME3021112225321 00:00:00 23:59:59 2 EE301218 08:05:35 20:56:35 MA301134 12:35:45 21:40:42 3 CS301111 15:30:28 17:00:10 SC3021234 08:00:00 11:25:25 CS301133 21:45:00 21:58:40
ME3021112225321 ME3021112225321 EE301218 MA301134 SC3021234 CS30113代码如下:#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> using namespace std; struct person{ char name[1000]; char start[8]; char end [8]; }; int cmp1(person a,person b) { return (strcmp(a.start,b.start)<=0); } int cmp2(person a,person b) { return (strcmp(a.end,b.end)>=0); } int main() { person a[100]; int t,b,c; scanf("%d",&t); while(t--) { int n,i; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%s %s %s",&a[i].name,&a[i].start,&a[i].end); } sort(a,a+n,cmp1); b=a[0]; sort(a,a+n,cmp2); c=a[0]; printf("%s %s\n",b.name,c.name); } }2115题Problem DescriptionDo you like playing basketball ? If you are , you may know the NBA Skills Challenge . It is the content of the basketball skills . It include several parts , such as passing , shooting , and so on. After completion of the content , the player who takes the shortest time will be the winner . Now give you their names and the time of finishing the competition , your task is to give out the rank of them ; please output their name and the rank, if they have the same time , the rank of them will be the same ,but you should output their names in lexicographic order.You may assume the names of the players are unique. Is it a very simple problem for you? Please accept it in ten minutes.InputThis problem contains multiple test cases! Ease test case contain a n(1<=n<=10) shows the number of players,then n lines will be given. Each line will contain the name of player and the time(mm:ss) of their finish.The end of the input will be indicated by an integer value of zero.OutputThe output format is shown as sample below. Please output the rank of all players, the output format is shown as sample below; Output a blank line between two cases.Sample Input10 Iverson 17:19 Bryant 07:03 Nash 09:33 Wade 07:03 Davies 11:13 Carter 14:28 Jordan 29:34 James 20:48 Parker 24:49 Kidd 26:46 0Sample OutputCase #1 Bryant 1 Wade 1 Nash 3 Davies 4 Carter 5 Iverson 6 James 7 Parker 8 Kidd 9 Jordan 10代码如下:Problem DescriptionDo you like playing basketball ? If you are , you may know the NBA Skills Challenge . It is the content of the basketball skills . It include several parts , such as passing , shooting , and so on. After completion of the content , the player who takes the shortest time will be the winner . Now give you their names and the time of finishing the competition , your task is to give out the rank of them ; please output their name and the rank, if they have the same time , the rank of them will be the same ,but you should output their names in lexicographic order.You may assume the names of the players are unique.
Is it a very simple problem for you? Please accept it in ten minutes.InputThis problem contains multiple test cases! Ease test case contain a n(1<=n<=10) shows the number of players,then n lines will be given. Each line will contain the name of player and the time(mm:ss) of their finish.The end of the input will be indicated by an integer value of zero.OutputThe output format is shown as sample below.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.Sample Input10 Iverson 17:19 Bryant 07:03 Nash 09:33 Wade 07:03 Davies 11:13 Carter 14:28 Jordan 29:34 James 20:48 Parker 24:49 Kidd 26:46 0Sample OutputCase #1 Bryant 1 Wade 1 Nash 3 Davies 4 Carter 5 Iverson 6 James 7 Parker 8 Kidd 9 Jordan 10
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
struct person
{
char name[1000];
char time[1000];
}
;
person a[6666];
bool cmp(person a,person b)
{
if(a.time!=b.time)
return strcmp(a.time,b.time)<0;
else
return strcmp(a.name,b.name)<0;
}
int main()
{
int n,i,j;
int c=0;
int t=1;
while(scanf("%d",&n)&&n)
{
if(t>1)
printf("\n");
for(i=1;i<=n;i++)
scanf("%s%s",a[i].name,a[i].time);
sort(a+1,a+n+1,cmp);
printf("Case #%d\n",++c);
for(i=1;i<=n;i++)
{
printf("%s %d\n",a[i].name,i);
if(strcmp(a[i].time,a[i+1].time)==0)
{
printf("%s %d\n",a[i+1].name,i);
i++;
}
}
t++;
}
return 0;
}
Is it a very simple problem for you? Please accept it in ten minutes.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.
10 Iverson 17:19 Bryant 07:03 Nash 09:33 Wade 07:03 Davies 11:13 Carter 14:28 Jordan 29:34 James 20:48 Parker 24:49 Kidd 26:46 0
Case #1 Bryant 1 Wade 1 Nash 3 Davies 4 Carter 5 Iverson 6 James 7 Parker 8 Kidd 9 Jordan 10
278



被折叠的 条评论
为什么被折叠?



