Pagini recente » Cod sursa (job #264507) | Cod sursa (job #2297066) | Cod sursa (job #2904397) | Cod sursa (job #2905940) | Cod sursa (job #2297044)
#include <fstream>
#include <string>
#include <unordered_set>
using namespace std;
ifstream in("abc2.in");
ofstream out("abc2.out");
int cnt, n, len, ans;
string ch;
string cuv;
unordered_set<string> dictionary;
int main()
{
ios_base::sync_with_stdio(false);
getline(in, ch);
while(!in.eof())
{
getline(in, cuv);
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());
}
out << ans;
return 0;
}