Cod sursa(job #2366106)

Utilizator Cristian25Cristian Stanciu Cristian25 Data 4 martie 2019 18:31:32
Problema Potrivirea sirurilor Scor 78
Compilator cpp-64 Status done
Runda pregatire_cls12_oji Marime 0.59 kb
#include <fstream>
#include <cstring>
#include <queue>
#define len 2000001

using namespace std;

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

queue<unsigned> q;

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

int main()
{
    in >> s >> t;
    while(true)
    {
        char *p = strstr(t + pos + 1, s);
        if(!p)
            break;
        pos = p - t;
        ++count;
        if(count <= 1000)
            q.push(pos);
    }
    out << count << '\n';
    while(!q.empty())
    {
        out << q.front() << ' ';
        q.pop();
    }
    return 0;
}