Pagini recente » Cod sursa (job #2750516) | Cod sursa (job #1445400) | Cod sursa (job #1689116) | Cod sursa (job #1631984) | Cod sursa (job #3144681)
#include <fstream>
#include <vector>
using namespace std;
// https://infoarena.ro/problema/strmatch
ifstream f("strmatch.in");
ofstream g("strmatch.out");
int main(void) {
string a, b;
f >> a >> b;
const int sza = a.size(), szb = b.size();
int t = 0;
vector<int> res;
for (int i = 0; i < szb - sza; i++) {
if (b[i] == a[0]) {
string tmp = b.substr(i, sza);
if (tmp == a) {
t++;
res.push_back(i);
}
}
}
g << t << endl;
for (int r : res) g << r << " ";
return 0;
}