Cod sursa(job #2230541)

Utilizator gavrisraulRaul Gavris gavrisraul Data 10 august 2018 14:58:21
Problema Potrivirea sirurilor Scor 14
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include <iostream>
#include <fstream>
#include <string.h>
#include <set>
using namespace std;

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

const int maxn=200000005;
char sa[maxn],sb[maxn],*p;
int nr;
set <int> st;
set <int> ::iterator it;
int main(){
  fin.getline(sa,maxn);
  fin.getline(sb,maxn);
  p=strstr(sb,sa);
  while(p){
    nr++;
    p=strstr(p+1,sa);
  }
  fout<<nr<<'\n';
  p=strstr(sb,sa);
  while(p){
    st.insert(strlen(p)+1);
    p=strstr(p+1,sa);
  }
  for(it=st.begin();it!=st.end();++it)
    fout<<*it<<' ';
  return 0;
}