#28 WA,求助
查看原帖
#28 WA,求助
270791
WanderingTrader楼主2020/7/3 22:34
#include <bits/stdc++.h>
using namespace std;
#define N 105 
string str[N] = {"11:59 p.m."};
bool smaller (const string& a,const string& b) 
{
	bool x = (a.find("a") != a.npos),y = (b.find("a") != b.npos);
	if(x && (!y)) return true;
	if((!x) && y) return false;
	int ha = (a[0] - '0')*10 + (a[1] - '0');
	int hb = (b[0] - '0')*10 + (b[1] - '0');
	int mina = (a[3] - '0')*10 + (a[4] - '0');
	int minb = (b[3] - '0')*10 + (b[4] - '0');
	if(ha == 12) ha = 0;
	if(hb == 12) hb = 0;
	if(ha != hb) return ha < hb;
	return mina < minb;
}
int main()
{
	int n,ans = 0,cnt = 1;
	scanf("%d",&n);
	getchar();
	for(int i = 1;i <= n;++ i)
	{
		getline(cin,str[i]);
		int x = str[i].find("]");
		str[i] = str[i].substr(1,x-1);
		if(str[i] == str[i-1])
		{
			if(cnt > 10) {cnt = 0;++ans;} 
			++cnt;
		}
		else if(smaller(str[i],str[i-1])) 
		{
			cnt = 1;
			++ ans;
		}
	}
	printf("%d\n",ans);
	return 0;
}

看不到全部的数据,所以也不知道哪错了,求助

2020/7/3 22:34
加载中...