Cod sursa(job #2366085)
| Utilizator | Data | 4 martie 2019 18:25:54 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 38 |
| Compilator | cpp-64 | Status | done |
| Runda | pregatire_cls12_oji | Marime | 0.54 kb |
#include <fstream>
#include <cstring>
#include <queue>
#define len 2000001
using namespace std;
ifstream in("strmatch.in");
ofstream out("strmatch.out");
queue<unsigned> q;
char s[len], t[len];
int main()
{
in >> s >> t;
q.push(0);
while(true)
{
char *p = strstr(t + q.back() + 1, s);
if(!p)
break;
q.push(p - t);
}
q.pop();
out << q.size() << '\n';
while(!q.empty())
{
out << q.front() << ' ';
q.pop();
}
return 0;
}
