题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3040
水题,排个序就好了。
///2014.4.3 - 2014.4.5
///hdu3040
///203MS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
struct Vote{
int time;
long long tel;
int num;
};
int N;
int girlGet[11];
int numOfVote;
Vote vote[50100];
void init(){
memset(girlGet,0,sizeof(girlGet) );
numOfVote = 0;
int h,m,s;
unsigned long long tel;
int num;
while( scanf("%d",&h)==1 ){
scanf(":%d:%d %llu %d\n",&m,&s,&tel,&num);
vote[numOfVote].time = h*3600 + m*60 + s ;
vote[numOfVote].tel = tel;
vote[numOfVote].num = num;
numOfVote++;
}
scanf("#end\n");
}
bool cmp(Vote A,Vote B){
if(A.tel > B.tel)
return false;
else if(A.tel < B.tel)
return true;
else
return A.time < B.time;
}
int main()
{
// freopen("in","r",stdin);
// freopen("out","w",stdout);
while( cin>>N ){
init();
sort(vote,vote+numOfVote,cmp);
girlGet[ vote[0].num ]++;
int ti = vote[0].time;
for(int i=1 ; i<numOfVote ; i++){
if( vote[i].tel==vote[i-1].tel ){
if( vote[i].time-ti >= 60 ){
ti = vote[i].time;
girlGet[ vote[i].num ]++;
}
}
else{
ti = vote[i].time;
girlGet[ vote[i].num ]++;
}
}
cout<<"The result is :"<<endl;
for(int i=1 ; i<=N ; i++){
printf("%02d : ",i );
for(int j=0 ; j<girlGet[i] ; j++){
printf("*");
}
cout<<endl;
}
}
return 0;
}