Codeforces Round #597 (Div. 2) C dp

Codeforces Round #597 (Div. 2) C dp_第1张图片


设dpi为前面长度为i的字符串的所有可能组合,如果 s[i]==s[i-1]并且s[i]∈{u,n}
那么dp[i]=dp[i-1]+dp[i-2]否则dp[i]=dp[i-1],最后结果就是dp[s[i].length]


#include
#include
using namespace std;
#define rep(i,j,k) for(LL i=(j); i<(k); ++i)
#define pb push_back
#define PII pair
#define PLL pair
#define ini(a,j) memset(a,j,sizeof a)
#define rrep(i,j,k) for(LL i=j; i>=k; --i)
#define fi first
#define se second
#define LL long long
#define beg begin()
#define ed end()
#define all(x) x.begin(),x.end()
const LL mod= 1e9+7;
const unsigned int N = 1e5+10;
string s;
LL dp[N];
int main(int argc, char const *argv[])
{
	// #define DEBUG
    	#ifdef DEBUG
		freopen("1.dat","r",stdin);
		freopen("ans.dat","w",stdout);
	#endif
	LL _=1;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin>>_;
	while(_--){
		cin>>s;
		if(count(all(s),'m')!=0||count(all(s),'w')!=0)
			cout<<0<

你可能感兴趣的:(Codeforces Round #597 (Div. 2) C dp)