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