Pagini recente » Cod sursa (job #1255684) | Cod sursa (job #2077877) | Cod sursa (job #557517) | Cod sursa (job #992492) | Cod sursa (job #1579670)
// 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";
}