Cod sursa(job #1911761)
| Utilizator | Data | 7 martie 2017 21:45:26 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <bits/stdc++.h>
using namespace std;
int nr=0;
vector<int> sol;
string a,b;
void read()
{
ifstream f("strmatch.in");
f>>a>>b;
f.close();
}
void match()
{
int pos=-1;
while(1)
{
pos=b.find(a,pos+1);
if(pos==-1) break;
nr++;
if(nr<=1000) sol.push_back(pos);
}
}
void write()
{
ofstream g("strmatch.out");
g<<nr<<"\n";
for(int i=0;i<min(nr,1000);i++) g<<sol[i]<<" ";
g.close();
}
int main()
{
read();
match();
write();
}
