Pagini recente » Cod sursa (job #1742824) | Cod sursa (job #1555101) | Cod sursa (job #369088) | Istoria paginii runda/pregarire_balti_oji_round1/clasament | Cod sursa (job #1579672)
// Problema Strmatch - InfoArena ( www.infoarena.ro/problema/strmatch )
#include <cstdio>
#include <string>
#include <unordered_map>
#include <fstream>
#include <vector>
#define in "strmatch.in"
#define out "strmatch.out"
#define len 2000007
#define pb push_back
using namespace std;
ifstream cin(in);
ofstream cout(out);
int sze1, sze2, nrSol, Hash;
string str1, str2, tmp;
unordered_map <string, bool> RabinKarp;
vector <int> vecSol;
int main()
{
cin >> str1 >> str2;
sze1 = str1.size();
sze2 = str2.size();
//Hash = RabinKarp.hash_function(str1);
for(int i = 0 ; i< sze2 - sze1 + 1; ++i)
{
tmp.replace(0, len, str2, i, sze1);
/*if(RabinKarp.key_eq(tmp, str1))
{
nrSol ++;
vecSol.pb(i);
}*/
}
cout << nrSol << "\n";
for(int i = 0; i< nrSol; ++i)
{
cout << vecSol[i] << " ";
}
cout << "\n";
}