67pts求条qwq
查看原帖
67pts求条qwq
1235038
Ekin123楼主2024/9/10 20:08
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	string s;
	int n;
	cin >> n;
	cin >> s;
	int maxn = -2e9;
	for(int i = 0;i <= n - 1;i++)
	{
		int cnt = 0;
		char c = '?';
		for(int j = n - 1;j >= 0;j--)
		{
			if(s[j] == 'w') cnt++;
			else
			{
				if(c == '?') c = s[j];
				if(c == s[j]) cnt++;
				else break;
			}
		}
		c = '?';
		for(int j = 0;j <= n - 1;j++)
		{
			if(s[j] == 'w') cnt++;
			else
			{
				if(c == '?') c = s[j];
				if(c == s[j]) cnt++;
				else break;
			}
		}
		maxn = max(maxn,cnt);
		string t = s.substr(1) + s[0];
		s = t;
	}
	cout << maxn << endl;
	return 0;
} 
2024/9/10 20:08
加载中...