WA20分求助!
查看原帖
WA20分求助!
544487
Ray_awa楼主2022/1/3 22:19

Visual Studio C++本地是对的,可洛谷他只有20分。

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
// 	FILE* stream1;
// 	freopen_s(&stream1, "1.in", "r", stdin);
// 	freopen_s(&stream1, "1.out", "w", stdout);
	string str, t;
	int cnt = 0;
	while (cin >> t)
	{
		str += (t);
		cnt++;
	}
	cout << cnt << ' ';
	cnt = 0;
	char ch = str[0];
	for (auto i = str.begin() + 1; i != str.end(); i++)
	{
		cnt++;
		if (i != str.end())
			if((*i)!=ch)
			{
				cout << cnt << ' ';
				cnt = 0;
				ch = *i;
			}
	}
	cout << cnt + 1;
	return 0;
}

2022/1/3 22:19
加载中...