Cod sursa(job #2917238)

Utilizator raresgherasaRares Gherasa raresgherasa Data 3 august 2022 21:14:49
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.4 kb
#include <bits/stdc++.h>

using namespace std;

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

const int NM = 2e5 + 5;

char s[NM], t[NM], *p;
vector<int>ans;

int main(){
  fin >> s >> t;
  p = strstr(t, s);
  while(p){
    ans.push_back(p - t);
    t[p - t] = '@';
    p = strstr(t, s);
  }
  fout << ans.size() << '\n';
  for (int x : ans){
    fout << x << " ";
  }
}