code:
#include <iostream>
#include <string>
#define debug(x) std::cout << #x << " = " << x << '\n'
int MaxBorder(std::string s){
int ans = 0;
for (int i = 0,j = s.length() - 1;i < j;i++,j--){
if (s[i] == s[j]) ans++;
else break;
}
return ans;
}
int main(){
#ifndef ONLINR_JUDGE
freopen("P3375.in","r",stdin);
freopen("P3375.out","w",stdout);
#endif
std::cin.tie(0)->sync_with_stdio(0);
int pos = -1;
std::string s1,s2,s = "";
std::cin >> s1 >> s2;
while ((pos = s1.find(s2,pos + 1)) != -1) std::cout << pos + 1 << '\n';
for (char c : s2) s += c,std::cout << MaxBorder(s) << ' ';
return 0;
}
我知道这不是正解,但也没有TLE,为什么WA?下载都对的!!!