Pagini recente » Cod sursa (job #2498520) | Cod sursa (job #718441) | Cod sursa (job #318101) | Cod sursa (job #811674) | Cod sursa (job #647296)
Cod sursa(job #647296)
#include<cstdio>
#include<string>
#include<vector>
#define Check() if (++i == 16384) {fread (buff, 1, 16384, stdin); i = 0;}
using namespace std;
string str1, str2;
vector <int> L;
size_t found;
char s1[2000001], s2[2000001], buff[16384];
int i;
inline void Read(char *s) {
int k = -1;
s[k + 1] = '\0';
while (buff[i] == '\n') Check();
while (buff[i] != '\n') {
s[++k] = buff[i];
Check();
}
s[++k] = '\0';
}
int main() {
freopen("strmatch.in", "r", stdin), freopen("strmatch.out", "w", stdout);
fread (buff, 1, 16384, stdin);
Read(s1); str1 = s1; //printf("%s\n", s1);
Read(s2); str2 = s2; //printf("%s\n", 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;
}