每天第一个到机房的人要把门打开,最后一个离开的人要把门关好。现有一堆杂乱的机房签
到、签离记录,请根据记录找出当天开门和关门的人。
到、签离记录,请根据记录找出当天开门和关门的人。
每天的记录在第一行给出记录的条目数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 CS301133
#include<iostream>
#include <cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct Student
{
char name[10];
int score;
char code[10];
}p[500000];
bool cmp1( Student x,Student y)
{ int t=strcmp(x.code,y.code);
if(t==-1)
return true;
else
return false;
}
bool cmp2(Student x,Student y)
{ if(strcmp(x.name,y.name))
{int t=strcmp(x.name,y.name);
if(t==-1)
return true;
else
return false;
}
else
{int t=strcmp(x.code,y.code);
if(t==-1)
return true;
else
return false;
}
}
bool cmp3(Student x,Student y)
{ if(x.score!=y.score)
return x.score<y.score;
else
{
int t=strcmp(x.code,y.code);
if(t==-1)
return true;
else
return false;
}
}
int main(){
int n,m;
int w=1;
while(cin>>n>>m)
{
if(n==0||m==0)
{
break;
}
for(int i=0;i<n;i++)
cin>>p[i].code>>p[i].name>>p[i].score;
if(m==1)
{
sort(p,p+n,cmp1);
cout<<"Case "<<w++<<":"<<endl;
for(int i=0;i<n;i++)
{
cout<<p[i].code<<" "<<p[i].name<<" "<<p[i].score<<endl;
}
}
else if(m==2)
{
sort(p,p+n,cmp2);
cout<<"Case "<<w++<<":"<<endl;
for(int i=0;i<n;i++)
{
cout<<p[i].code<<" "<<p[i].name<<" "<<p[i].score<<endl;
}
}
else if(m==3)
{
sort(p,p+n,cmp3);
cout<<"Case "<<w++<<":"<<endl;
for(int i=0;i<n;i++)
{
cout<<p[i].code<<" "<<p[i].name<<" "<<p[i].score<<endl;
}
}
}
return 0;
}