题目地址:http://ac.jobdu.com/problem.php?pid=1022
题目叙述,有大问题……很大的问题……冲突数据,竟然得保留前一个??按照后一个来算,竟然是错?可是题目说,冲突数据是由于线路原因造成的啊!俩冲突数据(假设俩S)的中间,必然因为线路漏了一个E!则,为啥要保留前一个数据???…各种想不通……
#include<stdio.h>
#include<string.h>
#define MAXS 104
typedef struct E{
int flag,t1,t2;
}E;
typedef struct Time{
char time[8];
int t;
void change()
{
int i,hour=0,minite=0;
hour=(time[0]-'0')*10+time[1]-'0';
minite=(time[3]-'0')*10+time[4]-'0';
t=hour*60+minite;
}
}Time;
int main()
{
char op;
int n,count;
float time;
E ship[MAXS];
Time temp;
while(~scanf("%d",&n)&&~n)
{
scanf(" %c %s",&op,temp.time);
if(n==0)
{
printf("0 0\n");
continue;
}
memset(ship,0,MAXS*sizeof(ship[0]));
time=count=0;
if(op=='S'){temp.change();ship[n].flag=1;ship[n].t1=temp.t;}
while(~scanf("%d %c %s",&n,&op,temp.time)&&n)
{
temp.change();
switch(op)
{
case 'S':if(ship[n].flag!=1){ship[n].flag=1;ship[n].t1=temp.t;}break;
case 'E':
if(ship[n].flag)
{
ship[n].t2=temp.t;
time=time+ship[n].t2-ship[n].t1;
ship[n].flag=0;
count++;
}
}
}
time=time/count;
printf("%d %.0f\n",count,time);
time=0.0;
}
return 0;
}