前言
上周写完题结果一直没时间(老颓狗了 ,写博客,咕咕
链接
题目描述
现在有一组n个字符串和另一组共m个字符串,其中n个字符串会有一些在这m个字符串中,记其数量为a,现在问你如何在这m个字符串中连续地选取一段,选完这a个字符串并且选择个数最少
样例输入
3
hot
dog
milk
5
hot
dog
dog
milk
hot
样例输出
3
3
思路
找出a的值,然后用尺取法求出最小长度
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int n, t, m, ans, ans1, sum;
int l[1000005], hash1[10005], hash2[10005];
bool b[100005];
string s;
struct str
{
int now, next;
}h[1000005];
int main()
{
scanf("%d