Cod sursa(job #2338026)

Utilizator Cristian25Cristian Stanciu Cristian25 Data 6 februarie 2019 21:54:34
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include <queue>
#include <fstream>
#include <cstring>
#define lim 1000
#define len 2000001
#define date "strmatch.in"
#define rezultate "strmatch.out"

using namespace std;

typedef unsigned int uint;

ifstream in(date);
ofstream out(rezultate);

queue<uint> q;

char A[len], B[len];
uint pos, count;

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