Cod sursa(job #2861613)
| Utilizator | Data | 4 martie 2022 10:03:06 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 26 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.67 kb |
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
string a, b;
vector <int> pos;
int cnt, c;
int main(){
fin>>a>>b;
if(a.size()>b.size()){
cout<<0;
}else{
for(int i=0;i<b.size()-a.size()+1;i++){
string c = b.substr(i, a.size());
if(c==a){
cnt++;
pos.push_back(i);
}
}
fout<<cnt<<'\n';
for(auto it: pos){
fout<<it<<" ";
c++;
if(c==1000){
break;
}
}
}
return 0;
}
