Cod sursa(job #1135287)
| Utilizator | Data | 7 martie 2014 17:13:04 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include<fstream>
#include<string>
using namespace std;
const int maxn = 2000000;
string s, t;
int urmator[maxn];
main(){
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
fin>>t>>s;
int k = 0;
int i, j, m = strlen(s);
urmator[0] = -1;
for(i = 0, j = -1; i < m; i++, j++, urmator[i] = j)
while(j >= 0 && s[i] != s[j])
j = urmator[j];
fout<<k<<"\n";
if(k>1001)k=1001;
for(int j=0;j<k;j++)fout<<a[j]<<" ";
}
