Cod sursa(job #1713022)
Utilizator | Data | 4 iunie 2016 15:06:31 | |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
#include <vector>
#include <cstring>
#define DN 2000005
using namespace std;
char a[DN],b[DN];
vector<int> sol;
int nrs;
int main() {
ifstream f("strmatch.in");
ofstream g("strmatch.out");
f>>a>>b;
char *p=strstr(b,a);
for(;p;p=strstr(p+1,a)) {
++nrs;
if(nrs<=1000) sol.push_back(p-b);
}
g<<nrs<<'\n';
for(auto i:sol) g<<i<<' ';
}