Pagini recente » Cod sursa (job #843406) | Cod sursa (job #1872208) | Cod sursa (job #1115582) | Cod sursa (job #2777994) | Cod sursa (job #2293942)
#include <bits/stdc++.h>
using namespace std;
char s[10000001], vocabular[50001], ch[50001], aux[10000001];
int main()
{
ifstream f("abc2.in");
ofstream g("abc2.out");
unordered_map<string, int > mp;
int l, nr = 0;
f>>s;
strcpy(aux, s);
while(f>>vocabular)
{
mp[vocabular] = 1;
l = strlen(vocabular);
}
int ll = strlen(s) ;
strcpy(aux + l, aux + ll);
strcpy(ch, aux);
if(mp.find(ch) != mp.end()) nr++;
for(int i = l; i < ll ; i++)
{
strcpy(ch, ch + 1);
ch[l - 1] = s[i];
if(mp.find(ch) != mp.end()) nr++;
}
g<<nr;
return 0;
}