Cod sursa(job #796058)

Utilizator Alexxino7Alexandru Popescu Alexxino7 Data 10 octombrie 2012 15:08:18
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include<fstream>
#include<string>
#include<vector>
using namespace std;

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

string A,B;
int N,M,Sol;
vector<int> Shift;

int main(){
	
	fin>>B;
	M=B.size();
	fin>>A;
	N=A.size();
	
	int i,j,ok;
	for(i=0;i<=N-M;i++){
		ok=1;
		for(j=0;j<M && ok;j++){
			if(A[i+j]!=B[j])
				ok=0;
		}
		if(ok){
			Sol++;
			if(Sol<=1000)
				Shift.push_back(i);
		}
	}
	
	fout<<Sol<<"\n";
	for(i=0;i<Sol && i<1000; i++){
		fout << Shift[i] <<" ";
	}
	fout<<"\n";
	
	return 0;
}