思路
dp
过程
代码
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
const int N = 1e6;
long long s, h, y;
int n;
string str;
int main()
{
cin >> n >> str;
for(int i = 0;i < n;i ++)
{
char ch = str[i];
if(ch == 's') s ++;
else if(ch == 'h') h += s;
else if(ch == 'y') y += h;
}
cout << y << endl;
return 0;
}