Cod sursa(job #879536)

Utilizator howsiweiHow Si Wei howsiwei Data 15 februarie 2013 16:22:25
Problema Potrivirea sirurilor Scor 38
Compilator cpp Status done
Runda Arhiva educationala Marime 0.54 kb
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

int main() {
	ifstream fin("strmatch.in");
	ofstream fout("strmatch.out");
	char a[2000000], s[2000000];
	fin >> a >> s;
	//cout << a << ' ' << s;
	char * match[10001];
	int i=0;
	match[0]=s;
	//cout << (match[1]=strstr(match[0],a));
	while (true) {
		match[i+1]=strstr(match[i]+1,a);
		if (match[++i]==NULL) break;
	}
	fout << i-1 << '\n';
	i=min(i,1001);
	for (int j=1; j<i; ++j) {
		fout << match[j]-s << ' ';
	}
	return 0;
}