Pagini recente » Cod sursa (job #2901259) | Cod sursa (job #2211266) | Cod sursa (job #3147464) | Cod sursa (job #264507) | Cod sursa (job #2297066)
#include <fstream>
#include <string>
#include <unordered_map>
using namespace std;
ifstream in("abc2.in");
ofstream out("abc2.out");
int cnt, n, len, ans;
string ch;
string cuv;
unordered_map<string, int> dictionary;
char temp[10000001];
char *tmp2;
int main()
{
ios_base::sync_with_stdio(false);
getline(in, ch);
while(!in.eof())
{
getline(in, cuv);
n = max(n, (int)cuv.length());
dictionary[cuv] = 1;
}
len = ch.length();
for(int i = 0; i < n; i++)
temp[i] = ch[i];
tmp2 = temp;
for(int i = n; i < len; i++)
{
string str(tmp2);
ans += (dictionary.find(str) != dictionary.end());
tmp2++;
temp[i] = ch[i];
}
string str(tmp2);
ans += (dictionary.find(str) != dictionary.end());
out << ans;
return 0;
}