Cod sursa(job #3284147)

Utilizator Piatra2007Pietraru Robert Constantin Piatra2007 Data 11 martie 2025 10:30:59
Problema Potrivirea sirurilor Scor 26
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include<fstream>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
char a[2000000];
char b[2000000];

ifstream f("strmatch.in");
ofstream g("strmatch.out");

int main() {
	f >> a;
	f >> b;
	char *p;
	int c = 0;
	vector<int> v;
	p = strstr(b,a);
	if (p == NULL){
		g << 0;
	} else {
		while (p != NULL){
			v.push_back(p-b);
			p = strstr(p+1,a);
		}
	}
	g << v.size() << endl;
	for (auto i : v){
		g << i << " " ;
	}
}