Cod sursa(job #1591145)

Utilizator alex_bucevschiBucevschi Alexandru alex_bucevschi Data 5 februarie 2016 20:11:28
Problema Potrivirea sirurilor Scor 80
Compilator cpp Status done
Runda Arhiva educationala Marime 0.74 kb
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ll long long
#define pii pair<int,int>
#define tii tuple <int,int,int>
#define N 2000001
#define mod 1000000005
#define X first
#define Y second
#define eps 0.0000000001
#define all(x) x.begin(),x.end()
#define tot(x) x+1,x+n+1
using namespace std;

ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
vector<int>sol;
int k;
char a[N], b[N], *p;
int main() {
    fin >> a >> b;
    p = strstr(b, a);

    while(p) {
        k++;

        if(k <= 1000)
            sol.pb(int(p - b));

        p = strstr(p + 1, a);
    }

    fout << k << '\n';

    for(auto it : sol)
        fout << it << ' ';

    return 0;
}