Pagini recente » Cod sursa (job #558281) | Cod sursa (job #3179276) | Cod sursa (job #806359) | Cod sursa (job #3131101) | Cod sursa (job #2661111)
#include <fstream>
#include <unordered_map>
#include <string>
#define desync ios::sync_with_stdio(0); fin.tie(0); fout.tie(0);
#define closef fout.close(); fin.close();
using namespace std;
ifstream fin("abc2.in");
ofstream fout("abc2.out");
unordered_map<string, int> h;
int main()
{
desync;
string s, txt;
fin >> s;
while(fin >> txt)
h[txt]++;
// for(int i = 1; i <= len; i++)
// cout << c uv[i] << " ";
int lgmax = txt.size();
// for(int i = 0; i <= 3; i++)
// cout << s[i];
// cout << "\n";
// for(int i = 0; i <= 4; i++)
// cout << s[i];
int j = lgmax, nrs = 0;
for(int i = 0; i <= s.size() - lgmax; i++)
{
string w = s.substr(i, j);
if(h[w] > 0)
{
nrs++;
h[w]--;
}
}
fout << nrs;
closef;
return 0;
}