Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int modulo=1e9+7;
- int main(){
- ios_base::sync_with_stdio(0); cin.tie(0);
- int t;
- cin >> t;
- while(t--){
- string a;
- cin >> a;
- int resp=1, aux=1, ult=-1;
- if(a[0]!='?')ult=0;
- for(int i=1; i<(int)a.size(); i++){
- if(a[i]=='?'){
- aux++;
- }
- else{
- if(ult==-1){
- aux++;
- }
- else if((i-ult)%2==0){
- if(a[i]==a[ult]){
- aux++;
- }
- else{
- aux=i-ult;
- }
- }
- else{
- if(a[i]!=a[ult]){
- aux++;
- }
- else{
- aux=i-ult;
- }
- }
- ult=i;
- }
- resp+=aux;
- resp%=modulo;
- }
- cout << resp << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement