Cod sursa(job #2366138)

Utilizator Cristian25Cristian Stanciu Cristian25 Data 4 martie 2019 18:39:01
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda pregatire_cls12_oji Marime 0.58 kb
#include <fstream>
#include <cstring>
#include <vector>
#define len 2000001
#define pb push_back

using namespace std;

ifstream in("strmatch.in");
ofstream out("strmatch.out");

vector<unsigned> v;

char s[len], t[len];
unsigned count, pos;

int main()
{
    in >> s >> t;
    while(true)
    {
        char *p = strstr(t + pos, s);
        if(!p)
            break;
        pos = p - t + 1;
        ++count;
        if(count <= 1000)
            v.pb(pos - 1);
    }
    out << count << '\n';
    for(auto i : v)
        out << i << ' ';
    return 0;
}