Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <cstdio>
- #include <iomanip>
- #include <vector>
- #include <set>
- #include <map>
- #include <algorithm>
- #include <cmath>
- #include <sstream>
- #include <string>
- #include <memory.h>
- using namespace std;
- void prepare()
- {
- #ifdef _DEBUG
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- #endif
- cin.sync_with_stdio(false);
- cout.sync_with_stdio(false);
- }
- int main()
- {
- prepare();
- int n;
- cin >> n;
- for (int j = 0; j < n; j++)
- {
- string s;
- long long res = 1;
- int k = 0, q = 0;
- cin >> s;
- for (int i = 0; i < s.length(); i++)
- if (s[i] == '?')
- k++;
- for (int i = 0; i < k; i++)
- res = (res * 2) % (1000 * 1000 * 1000 + 7);
- if (s.length() % 2)
- cout << res;
- else
- {
- bool flag = 0;
- int q = s.length()/2;
- int t = 0;
- for (int i = 0; i < q; i++)
- {
- if (!(s[i] == s[i + q] || s[i] == '?' || s[i + q] == '?'))
- flag = 1;
- if (s[i] == '?' && s[i + q] == '?')
- t++;
- }
- if (flag)
- cout << res;
- else
- cout << res - 1 - t;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement