16D. Logging

D. Logging
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output

The main server of Gomble company received a log of one top-secret process, the name of which can't be revealed. The log was written in the following format: «[date:time]: message», where for each «[date:time]» value existed not more than 10 lines. All the files were encoded in a very complicated manner, and only one programmer — Alex — managed to decode them. The code was so complicated that Alex needed four weeks to decode it. Right after the decoding process was finished, all the files were deleted. But after the files deletion, Alex noticed that he saved the recordings in format «[time]: message». So, information about the dates was lost. However, as the lines were added into the log in chronological order, it's not difficult to say if the recordings could appear during one day or not. It is possible also to find the minimum amount of days during which the log was written.

So, to make up for his mistake Alex has to find the minimum amount of days covered by the log. Note that Alex doesn't have to find the minimum amount of days between the beginning and the end of the logging, he has to find the minimum amount of dates in which records could be done. (See Sample test 2 for further clarifications).

We should remind you that the process made not more than 10 recordings in a minute. Consider that a midnight belongs to coming day.

Input

The first input line contains number n (1 ≤ n ≤ 100). The following n lines contain recordings in format «[time]: message», where time is given in format «hh:mm x.m.». For hh two-digit numbers from 01 to 12 are used, for mm two-digit numbers from 00 to 59 are used, and x is either character «a» or character «p». A message is a non-empty sequence of Latin letters and/or spaces, it doesn't start or end with a space. The length of each message doesn't exceed 20.

Output

Output one number — the minimum amount of days covered by the log.

Examples
input
5
[05:00 a.m.]: Server is started
[05:00 a.m.]: Rescan initialized
[01:13 p.m.]: Request processed
[01:10 p.m.]: Request processed
[11:40 p.m.]: Rescan completed
output
2
input
3
[09:00 a.m.]: User logged in
[08:00 a.m.]: User logged in
[07:00 a.m.]: User logged in
output
3
Note

Formally the 12-hour time format is described at:

  • http://en.wikipedia.org/wiki/12-hour_clock.
The problem authors recommend you to look through these descriptions before you start with the problem.

注意:12:00 am 是凌晨12:00,是一天的开始,12:00 pm 是中午十二点,是一天过了一半了 


#include<cstdio>
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int a,b;
		char log[50];
		int x[105]={0x3f3f3f3f},time[105]={0};
		getchar();
		for(int i=1;i<=n;++i)
		{
			gets(log);
			a=(log[1]-'0')*10+(log[2]-'0');
			b=(log[4]-'0')*10+(log[5]-'0');
	
			if(log[7]=='a'&&a==12)//上午12:00 am 是凌晨? 
			{
				a=0;
			}
			
			if(log[7]=='p'&&a!=12)
			{
				a+=12;
			}
			x[i]=a*60+b;
			if(x[i]==x[i-1])
			{
				time[i]=time[i-1]+1;
				time[i]%=10;
			}
		}
		int answer=0;
		for(int i=1;i<=n;++i)
		{
			if(x[i-1]>x[i])
			{
				answer+=1;
			}
			else if(x[i]==x[i-1])
			{
				if(time[i]==0)
				{
					answer+=1;
				}
			}
		}
		printf("%d\n",answer);
	}
	return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值