求助大佬:所有样例在本地都能过,但是传上去都是TLE
查看原帖
求助大佬:所有样例在本地都能过,但是传上去都是TLE
584612
Matrix_zero楼主2022/2/14 17:34

代码如下:

#include<iostream>
#include<string>
#include<cctype>
using namespace std;
inline void geshi(string&);
inline bool exam(string&, string&);
int main() {
	string word;
	string article_temp;
	int cnt = 0, first = 0;
	char ch{};
	getline(cin, word);
	geshi(word);
	do {
		cin >> article_temp;
		ch = cin.get();
		geshi(article_temp);
		if (!exam(article_temp, word)) {
			first++;
			continue;
		}
		cnt++;
		break;
	} while (ch != '\n');
	if (cnt != 0 && ch != '\n')
	{
		do {
			cin >> article_temp;
			ch = cin.get();
			geshi(article_temp);
			if (exam(article_temp, word))
				cnt++;
		}while (ch != '\n');
	}
	if (cnt != 0)
		cout << cnt << " " << first;
	else
		cout << "-1";
}
inline void geshi(string& word) {
	for (int i = 0; word[i]; i++)
		if (isupper(word[i]))
			word[i] = char(word[i] + 32);
}
inline bool exam(string& a, string& b) {
	if (a == b) return 1;
	return 0;
}
2022/2/14 17:34
加载中...