超大型LED显示屏
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 267 Solved: 145
[ Submit][ Status][ Web Board]
Description
Input
输入包含不超过100组数据。每组数据第一行为"START hh:mm:ss",表示比赛开始时刻为hh:mm:ss。最后一行为"END hh:mm:ss",即比赛结束时刻。二者之间至少会有一个SCORE信息,格式为"SCORE hh:mm:ss team score",其中team要么是"home"(主场)要么是"guest"(客场), score表示得分,为1,2或者3。这些信息保证按照时间从早到晚的顺序排列,且任意两条SCORE信息的时刻均不相同。比赛开始时间不会早于9:00,结束时间不会晚于同一天的21:00。注意,如果比赛开始时间为09:00:00,结束时间为09:00:01,比赛长度为1秒钟,而不是2秒钟。
Output
对于每组数据,输出测试点编号和总耗电量。
Sample Input
START 09:00:00
SCORE 09:01:05 home 2
SCORE 09:10:07 guest 3
END 09:15:00
START 09:00:00
SCORE 10:00:00 home 1
SCORE 11:00:00 home 1
SCORE 12:00:00 home 1
SCORE 13:00:00 home 1
SCORE 14:00:00 home 1
SCORE 15:00:00 home 1
SCORE 16:00:00 home 1
SCORE 17:00:00 home 1
SCORE 18:00:00 home 1
SCORE 19:00:00 home 1
SCORE 20:00:00 home 1
END 21:00:00
Sample Output
Case 1: 9672
Case 2: 478800
HINT
一个模拟题就是当时没看清楚时间是不用显示的
才打了被注释掉那么多没用的代码
再仔细想想,时间都是成段的,因此就算要算的话
也应该预处理一些时间段,这样速度会快很多,一秒一秒的跑的话,太慢了
#include <iostream>
#include <stdio.h>
using namespace std;
char s[10];
char hg[10];
int co[10]={6,2,5,5,4,5,6,3,7,6};
int inline chan(int nhor,int hor,int nmin,int mi,int nsec,int sec)
{
return (nhor-hor)*3600+(nmin-mi)*60+nsec-sec;
}
int scoco(int sc)
{
if(sc==0)
return 6;
int cos=0;
while(sc>0)
{
cos+=co[sc%10];
sc/=10;
}
return cos;
}
//int ticoco(int t)
//{
// return co[t%10]+co[t/10];
//}
//
//int tico(int nhor,int hor,int nmin,int mi,int nsec,int sec)
//{
// int cos=0;int i=1;
// while(1)
// {
// if(sec==59)
// {
// sec=0;
// mi++;
// if(mi==60)
// {
// mi=0;
// hor++;
// }
// }
// else
// sec++;
//
// cout<<hor<<" "<<mi<<" "<<sec<<endl;
// cos+=ticoco(sec)+ticoco(mi)+ticoco(hor);
// i++;if(i>100)break;
// if(nhor==hor&&nmin==mi&&nsec==sec)
// break;
// }
// return cos;
//}
int main()
{
int hor,mi,sec;
int nhor,nmin,nsec;
int ho,gu;
int sc;
int cost;
int ca=1;
while(scanf("%s",s)!=EOF)
{
scanf("%d:%d:%d",&hor,&mi,&sec);
//cout<<hor<<" "<<mi<<" "<<sec<<endl;
ho=0,gu=0;cost=0;
while(1)
{
scanf("%s",s);
if(s[0]=='E')
{
scanf("%d:%d:%d",&nhor,&nmin,&nsec);
int time=chan(nhor,hor,nmin,mi,nsec,sec);
//cout<<scoco(ho)<<" "<<scoco(gu)<<" "<<time<<endl;
cost+=(scoco(ho)+scoco(gu))*time;
//cost+=tico(nhor,hor,nmin,mi,nsec,sec);
hor=nhor;mi=nmin;sec=nsec;
break;
}
if(s[0]=='S')
{
scanf("%d:%d:%d%s%d",&nhor,&nmin,&nsec,hg,&sc);
//cout<<nhor<<" "<<nmin<<" "<<nsec<<endl;
int time=chan(nhor,hor,nmin,mi,nsec,sec);
cost+=(scoco(ho)+scoco(gu))*time;
//cost+=tico(nhor,hor,nmin,mi,nsec,sec);
//cout<<"2";
hor=nhor;mi=nmin;sec=nsec;
if(hg[0]=='h')
ho+=sc;
else
gu+=sc;
}
}
printf("Case %d: %d\n",ca++,cost);
}
return 0;
}