Pagini recente » Cod sursa (job #757076) | Cod sursa (job #1077852) | Profil stay_awake77 | Cod sursa (job #2079003) | Cod sursa (job #1844462)
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
freopen("strmatch.in", "r", stdin);
freopen("strmatch.out", "w", stdout);
string a, b;
vector<int> ans;
cin >> a >> b;
int i = (int) a.size() - 1; // a
int j = (int) a.size() - 1; // b
while (j < b.size() && ans.size() <= 100) {
bool match = true;
for (int k = 0; k < a.size(); ++k) {
if (a[i - k] != b[j - k]) {
match = false;
break;
}
}
if (match) {
ans.push_back(j - i);
}
++j;
}
cout << ans.size() << '\n';
for (int x : ans) {
cout << x << ' ';
}
return 0;
}