UVA(WA) 409 借口借口

想用一下STL里面的set

肿么就老是WA呢???为什么呢?

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <cctype>
using namespace std;
///
#define INF 0xffffff7
#define MAXN 200

int K, E; //k means k keywords  E means E words to be searched
vector<string> excuses;  //借口单词数组
vector<string> lines;    //单行每一句借口
vector<int>    maxpos;   //最大关键词借口下标
set<string> keyWords;    //关键词集合
int maxnum;
int times[2000];

int main()
{
	///
	int i, j, th;
	int cases = 1;
	while (cin >> K >> E)
	{
		keyWords.clear();
		maxnum = 0;
		memset(times, 0, sizeof(times));
		//读入关键字
		for (i = 0; i < K; i++)
		{
			string temp;
			cin >> temp;
			keyWords.insert(temp);			
		}
//		getchar();
		cin.ignore();  //去掉输入流中的回车
		//读入句子
		lines.clear();
		maxpos.clear();
		for (i = 0; i < E; i++)
		{
			excuses.clear();
			string line, temp;
			getline(cin, line);
			lines.push_back(line);
			istringstream stream(line);
			while(stream >> temp)
			{
				while ((temp.size() != 0) && (!(    (islower(temp[temp.size() - 1])) || (isupper(temp[temp.size() - 1]))    )  )    )
				{
					temp.erase(temp.end() - 1);
				}
				if (temp.size() != 0)
				{
					for (j = 0; j < temp.size(); j++)
					{
						if (isupper(temp[j]))
						{
							temp[j] -= 'A' - 'a';
						}
					}
					excuses.push_back(temp);
				}
			}
			int timess = 0;
			vector<string>::iterator itor = excuses.begin();
			for ( ; itor != excuses.end(); itor++)
			{
				timess += keyWords.count(*itor);
			}
			times[i] = timess;
			if (timess > maxnum)
				maxnum = timess;
		}
		for (i = 0; i < E; i++)
		{
			if (times[i] == maxnum)
				maxpos.push_back(i);
		}
		cout << "Excuse Set #" << cases << endl;
		vector<int>::iterator maxpositor = maxpos.begin();
		for ( ;maxpositor != maxpos.end(); maxpositor++)
		{
			cout << lines[*maxpositor] << endl;
		}
		cout << endl;
		cases++;
	}
	///
    return 0;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值