77分求救
查看原帖
77分求救
918770
_HJS_楼主2023/8/22 10:07
/*****************************************
备注:
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1000000 + 10;
const int INF = 0x3f3f3f3f;
char str[N];
signed main()
{
	int n,m;
	cin>>n>>m;
	int ans=0,cnt=0;
	for(int i=1;i<=m;i++)
	{
		cin>>str[i];
		if(i==1&&str[i]=='Y')
		{
			cout<<"No solution"<<endl;
			return 0;
		}
		if(str[i]=='N')
		{
			ans++;
		}
		else
		{
			cnt++;
		}
	}
	int k=0;
	if(ans>=n||ans==0||cnt>=n)
	{
		cout<<"No solution\n";
	}
	else
	{
		for(int i=1;i<=m;i++)
		{
			if(str[i]=='N')
			{
				k++;
				cout<<k<<" ";	
			}
			if(str[i]=='Y')
			{
				if(k!=0)
				{
					cout<<"1"<<" ";
				}
			}
		}
	}
	return 0;
}

2023/8/22 10:07
加载中...