Cod sursa(job #1915117)
| Utilizator | Data | 8 martie 2017 19:46:08 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 14 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
vector<int> sol;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
int i, p = -1, ns = 0;
string a, b;
int main()
{
f >> a >> b;
while(true){
p = b.find(a, p+1);
if(p == -1)
break;
ns++;
if(ns<=1000)
sol.push_back(p);
}
g << ns << "\n";
ns = min(ns, 1000);
for(i=1; i<=ns; i++)
g << sol[i] << " ";
g << "\n";
}
