Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <list>
- #include <map>
- #include <set>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <bitset>
- #include <algorithm>
- #include <functional>
- #include <numeric>
- #include <utility>
- #include <sstream>
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #define ull unsigned long long
- #define ll long long
- #define pii pair<int,int>
- #define pb(x) push_back(x)
- #define S(x) scanf("%d",&x)
- #define Sl(x) scanf("%lld",&x)
- #define M(x,i) memset(x,i,sizeof(x))
- #define F(i,a,n) for(int i=(a);i<(n);++i)
- #define FD(i,a,n) for(i=(a);i>=(n);--i)
- using namespace std;
- class Softmatchd2 {
- public:
- int dp[55];
- int valid(char x,char y,char z){
- if(x == y){
- return 1;
- }
- if( z == 'a' || z=='A'){
- return (x == '0' && y == '1') || (x == '1' && y == '0') || (x=='2'&& y == '3') || (x=='3' && y == '2');
- }
- if( z == 'b' || z=='B'){
- return (x == '0' && y == '2') || (x == '2' && y == '0') || (x=='1'&& y == '3') || (x=='3' && y == '1');
- }
- return 0;
- }
- int count(string s, string p) {
- int lens = s.length();
- int lenp = p.length();
- int ans = 0;
- F(i,0,lens){
- if(i>=(lenp-1)){
- dp[i] = 1;
- }
- F(j,0,i){
- int flg = 0;
- if((i-lenp+1)<0)continue;
- F(k,0,lenp){
- int ind1 = i - lenp + 1 + k;
- if(ind1<=j){
- int ind2 = ind1 - ( j - lenp + 1);
- if(!valid(p[k],p[ind2],s[ind1])){
- flg = 1;
- break;
- }
- } else {
- break;
- }
- }
- if(flg == 0){
- dp[i] = max(dp[i],dp[j]+1);
- }
- }
- ans = max(ans,dp[i]);
- }
- return ans;
- }
- };
Add Comment
Please, Sign In to add comment