Pagini recente » Rezultatele filtrării | preONI 2008 - Clasament Runda 1, Clasele 11-12 | Cod sursa (job #1175310) | Rezultatele filtrării | Cod sursa (job #2983418)
#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
string A, B;
int k, poz[2000005];
int main()
{
fin >> A >> B;
size_t pos = B.find(A);
while(pos != string::npos)
{
poz[k++] = pos;
pos = B.find(A, pos + 1);
}
fout << k << '\n';
if(k <= 1000)
{
for(int i = 0; i < k; i++)
fout << poz[i] << ' ';
}
else
{
for(int i = 0; i < 1000; i++)
fout << poz[i] << ' ';
}
return 0;
}