Cod sursa(job #2675049)

Utilizator Casian_doispeChiriac Casian Casian_doispe Data 21 noiembrie 2020 09:40:27
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.05 kb
#include <fstream>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <cstring>
#include <cstring>
#define MOD 1234

using namespace std ;

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

string a, b ;

vector<int> v ;

int main()
{

    cin >> a >> b ;

    if(a.size() == 1)
    {

        int s = 0 ;

        for(int f = 0 ; f < b.size() ; f ++)
            if(b[f] == a[0])v.push_back(f) ;

        cout << v.size() << endl ;

        for(int f = 0 ; f < v.size() && f < 1000 ; f ++)
        cout << v[f] - 1 << " " ;

        return 0 ;

    }

    int s = 0 ;

    char *ptr = &b[0] ;

    while(strstr(ptr, &a[0]))
    {

        s ++ ;

        ptr = strstr(ptr, &a[0]) + 1 ;

        if(ptr)v.push_back(ptr - &b[0]) ;

    }

    cout << v.size() << endl ;

    for(int f = 0 ; f < v.size() && f < 1000 ; f ++)
        cout << v[f] - 1 << " " ;

    return 0 ;

}