Cod sursa(job #1374936)
| Utilizator | Data | 5 martie 2015 11:27:26 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.54 kb |
#include<fstream>
#include<cstring>
#include<vector>
#define maxN 2000001
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char s1[maxN],s2[maxN],*p;
int nr;
vector<int> sol;
int main()
{
f>>s1>>s2;
p=strstr(s2,s1);
if(p)
{
nr=1;
sol.push_back(p-s2);
while(p = strstr(p+1,s1) )
{
sol.push_back(p-s2);
nr++;
}
}
g<<nr<<'\n';
for(auto &e: sol)
g<<e<<" ";
return 0;
}
