Pagini recente » Cod sursa (job #2904447) | Cod sursa (job #1454663) | Cod sursa (job #3147451) | Cod sursa (job #2904395) | Cod sursa (job #2297052)
#include <cstdio>
#include <string>
#include <cstring>
#include <unordered_set>
using namespace std;
/*ifstream in("abc2.in");
ofstream out("abc2.out");*/
int cnt, n, len, ans;
char ch2[10000001];
string ch;
string cuv;
unordered_set<string> dictionary;
int main()
{
//ios_base::sync_with_stdio(false);
freopen("abc2.in", "r", stdin);
freopen("abc2.out", "w", stdout);
fgets(ch2, 10000000, stdin);
ch2[strlen(ch2) - 1] = '\0';
ch = string(ch2);
//getline(in, ch);
while(fgets(ch2, 20, stdin))
{
//getline(in, cuv);
ch2[strlen(ch2) - 1] = '\0';
cuv = string(ch2);
n = max(n, (int)cuv.length());
dictionary.insert(cuv);
}
len = ch.length();
for(int i = 0; i < len - n + 1; i++)
{
char temp[21] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'};
for(int j = 0; j < n; j++)
temp[j] = ch[i+j];
string str(temp);
ans += (dictionary.find(str) != dictionary.end());
}
printf("%d", ans);
return 0;
}