数据有点水,一下错误代码可以通过:
#include <bits/stdc++.h>
#define IL inline
using namespace std;
IL int read ()
{
int x = 0, f = 1;
char ch = getchar ();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar ();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar ();
}
return x * f;
}
IL void white (int x)
{
if (x < 0)
{
x = -x;
putchar ('-');
}
if (x > 9)
white (x / 10);
putchar (x % 10 + '0');
}
string s;
int main ()
{
int n, m, ans = 0, y = 1, cnt = 1;
n = read (), m = read (); cin >> s;
for (int i = 0; i < s.size (); i ++)
if (s[i] == 'N')
ans ++;
if (!ans || ans > n || s[0] == 'Y')
{
puts ("No solution");
return 0;
}
ans = 1;
for (int j = 0; j < s.size (); j ++)
{
if (s[j] == 'N')
cout << ans ++ << " ";
else
{
if (cnt == n)
{
cout << ++ y << " ";
cnt = 0;
}
else
cout << y << " ";
cnt ++;
}
}
return 0;
}
这题不是很难,只是模拟。并且只用到了基本语句 if 和 for 所以申请降红。
数据希望能加强。