Cod sursa(job #1579672)

Utilizator fluture.godlikeGafton Mihnea Alexandru fluture.godlike Data 24 ianuarie 2016 22:38:58
Problema Potrivirea sirurilor Scor 14
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
// 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";
}