Cod sursa(job #3212208)

Utilizator AlexMoto2006Motoasca Alexandru-Lucian AlexMoto2006 Data 11 martie 2024 12:32:26
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.73 kb
// ConsoleApplication2.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <fstream>
#include <vector>
#include <string>

using namespace std;

ifstream cin("strmatch.in");
ofstream cout("strmatch.out");

string A, B;
int pos;
vector <int> app;

int main() {
    cin >> A >> B;
    if (A.size() > B.size()) {
		cout << 0;
		return 0;
	}
    pos = B.find(A);
    while (pos != string::npos)
    {
		app.push_back(pos);
		pos = B.find(A, pos + 1);
	}
    cout << app.size() << "\n";
    if(app.size() < 1000)
    for(int i=0;i<app.size();i++)
		cout << app[i] << " ";
    else
       for (int i = 0; i < 1000; i++)
           cout << app[i] << " ";
    return 0;
}