题意:给定两个字符串s,t,要求从s中删去一些t子串(将连续的t子串改为.),以保证s中不存在t子串,求出最小的删除次数,同时,求出删除的所有方法数
思路:
贪心的错误思路:将s中的t字段处理成一个个线段,问题就转化为了求最小覆盖线段的选择线段的最小数及选择方法,排序后,从小向大,处理每一个线段的覆盖,并累乘覆盖的方法数,这么做能保证最小的选择次数,但是不能保证找出所有方法,原因在于并不是每一种覆盖模式都是按照选择中间的线段覆盖两边的模式,比如最后一个样例aaaaaaaaa,aa,6种方法中,按这样的思路只能找到一种方案
贴一贴错误代码
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<bitset>
#include<cmath>
#include<array>
#include<atomic>
#include<sstream>
#include<stack>
#include<iomanip>
//#include<bits/stdc++.h>
//#define int ll
#define IOS std::ios::sync_with_stdio(false);std::cin.tie(0);
#define pb push_back
#define endl '\n'
#define x first
#define y second
#define Endl endl
#define pre(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,b,a) for(int i=b;i>=a;i--)
#define si(x) scanf("%d", &x);
#define sl(x) scanf("%lld", &x);
#define ss(x) scanf("%s", x);
#define YES {puts("YES");return;}
#define NO {puts("NO"); return;}
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
typedef pair<char, int> PCI;
typedef pair<