generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bf3dc3
commit a5ae4c7
Showing
1 changed file
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
// Write Your Code Here | ||
// Write Your Code Here | ||
#include<iostream> | ||
#include<vector> | ||
#include<string> | ||
typedef long long int ll; | ||
#define MOD 998244353 | ||
using namespace std; | ||
|
||
|
||
int main(){ | ||
int t; | ||
cin>>t; | ||
while(t--){ | ||
string s; | ||
cin>>s; | ||
|
||
int n=s.length(); | ||
vector<ll> vec(n); | ||
vec[0]=1; | ||
vec[1]= vec[0]+ (s[0]!=s[1]); | ||
for(int i=2; i<n; i++){ | ||
if(s[i]!=s[i-1]){ | ||
vec[i]=(vec[i-1]+vec[i-2])%MOD; | ||
}else{ | ||
vec[i]=vec[i-1]; | ||
} | ||
} | ||
cout<<vec[n-1]<<endl; | ||
} | ||
} |