题目链接:http://codeforces.com/problemset/problem/39/J
给了两个字符串,在第一个字符串中删除一个字符,使得两个字符串相同。保证第一个字符串的长度比第二个字符串长度多一。
求出LCP, LCS。
首先判断无解的情况。
L = max(1, n - s), R = min(n, p + 1) .
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
#include <iomanip>
using namespace std;
#define rep(i, a, b) for( i = (a); i <= (b); i++)
#define reps(i, a, b) for( i = (a); i < (b); i++)
#define pb push_back
#define ps push
#define mp make_pair
#define CLR(x,t) memset(x,t,sizeof x)
#define LEN(X) strlen(X)
#define F first
#define S second
#define Debug(x) cout<<#x<<"="<<x<<endl;
const double euler_r = 0.57721566490153286060651209;
const double pi = 3.141592653589793238462643383279;
const int inf=~0U>>1;
const int MOD = int(1e9) + 7;
const double EPS=1e-6;
typedef long long LL;
char s1[1000010], s2[1000010];
int main()
{
int i, l1, l2, j;
scanf("%s%s", s1, s2);
l2 = LEN(s2);
l1 = l2 + 1;
int p, s;
p = s = 0;
while(p < l2 )
{
if(s1[p] != s2[p]) break;
p++;
}
for(i = l1 - 1, j = l2 - 1; i >= 0 && j >= 0; i--, j--)
{
if(s1[i] != s2[j]) break;
else s++;
}
// Debug(p);
// Debug(s);
if(p + s + 1 < l1)
{
cout << "0" << endl;
}
else
{
int L, R;
L = max(1, l1 - s);
R = min(l1, p + 1);
cout << R - L + 1 << endl;
rep(i, L, R) cout << i << " ";
cout << endl;
}
return 0;
}