Pagini recente » Cod sursa (job #455140) | Cod sursa (job #2388810) | Cod sursa (job #2146480) | Borderou de evaluare (job #702940) | Cod sursa (job #2872518)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("abc2.in");
ofstream fout("abc2.out");
char a[10000005];
string cuv[25];
int nrcuv, n, cnt;
int main()
{
int i, j, L;
string c;
bool gasit;
char cr[25], t[25];
fin >> a;
for (nrcuv = 1; fin >> cuv[nrcuv]; nrcuv++);
nrcuv--;
sort(cuv + 1, cuv + nrcuv + 1);
n = nrcuv;
c = cuv[1];
L = c.size();
for (i = 2; i <= nrcuv; i++)
if (cuv[i] == c)
{
for (j = 0; j < L; j++)
cuv[i][j] = 'z';
cuv[i] += 'z';
n--;
}
else c = cuv[i];
sort(cuv + 1, cuv + nrcuv + 1);
L--;
for (i = 0; i <= L; i++)
cr[i] = a[i];
gasit = 0;
for (i = 1; i <= n && gasit == 0; i++)
if (cr == cuv[i])
{
cnt++;
gasit = 1;
}
for (i = L + 1; i < strlen(a); i++)
{
strcpy(t, cr + 1);
strcpy(cr, t);
cr[L] = a[i];
gasit = 0;
for (j = 1; j <= n && gasit == 0; j++)
if (cr == cuv[j])
{
cnt++;
gasit = 1;
}
}
fout << cnt << "\n";
fin.close();
fout.close();
return 0;
}