Cod sursa(job #645266)

Utilizator the_snyper06FMI - ALexandru Mihai the_snyper06 Data 8 decembrie 2011 22:19:19
Problema Potrivirea sirurilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.87 kb
#include<cstdio>
#include<string>
#include<vector>
#define Check() if (++i == 80001) {fread (buff, 1, 80001, stdin); i = 0;}

using namespace std;
string str1, str2;
vector <int> L;
size_t found;
char s1[2000001], s2[2000001], buff[80001];
int i;

inline void Read(char *s) {
	strcpy(s, "\0");
	int k = -1;
	while (buff[i] < 'A' || buff[i] > 'Z') Check();
	while (buff[i] >= 'A' && buff[i] <= 'Z'){
		s[++k] = buff[i];
		Check();
	}
	s[++k] = '\0';
}

int main() {
	
	freopen("strmatch.in", "r", stdin), freopen("strmatch.out", "w", stdout);
	Read(s1); str1 = s1;
	Read(s2); str2 = s2;
	
	found = str2.find(str1);
	while(found != string::npos) {
		L.push_back(int(found));
		found = str2.find(str1, found + 1);
	}
	
	printf("%d\n", L.size());
	for(int i = 0; i < int(L.size()) && i < 1000; i++)
		printf("%d ", L[i]);
	printf("\n");
	
	return 0;
}