Cod sursa(job #1286907)

Utilizator GrandmasterSoucup Bogdan Grandmaster Data 7 decembrie 2014 13:20:32
Problema Potrivirea sirurilor Scor 38
Compilator cpp Status done
Runda Arhiva educationala Marime 1.06 kb
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <utility>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <sstream>
#include <deque>
#include <bitset>
#include <complex>
#include <functional>
#include <memory>
#include <numeric>
#define x first
#define y second
typedef std::pair<int, int> pii;

using namespace std;

char a[2000002], b[2000002];

int main () {
	int k = 0, ii, jj, moi = 0, mo[200002], vl = 0;
	ifstream fin("strmatch.in");
	ofstream fout("strmatch.out");
	fin.get(a, 2000002);
	fin.get();
	fin.get(b, 2000002);
	for(int j = 0; j < strlen(b); j++)
	{
		ii = 0;
		jj = j;
		while(a[ii] == b[jj])
		{
			ii++; 
			jj++;
			moi++;
		}
		if(ii == strlen(a))
		{
			mo[k] = jj - moi;
			k++; 
		}
		else
			moi = 0;
	}
	fout << k << "\n";
	for(int i = 0; i < k; i++)
		fout << mo[i] << " ";
	return 0;
}