Pagini recente » Cod sursa (job #469835) | Cod sursa (job #1865424) | Cod sursa (job #3147654) | Cod sursa (job #3211951) | Cod sursa (job #2297059)
#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;
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 < 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;
}