Pagini recente » Cod sursa (job #1501641) | Cod sursa (job #1512727) | Cod sursa (job #1582233) | Cod sursa (job #1659613) | Cod sursa (job #2661006)
#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 len;
int main()
{
desync;
string s, txt;
fin >> s >> 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];
for(int i = 0, j = i + lgmax; i <= s.size() - lgmax; i++)
{
string w = s.substr(i, j);
h[w]++;
}
int nrs = 0;
if(h[txt] > 0) nrs += h[txt];
while(fin >> txt)
{
if(h[txt] > 0)
{
nrs += h[txt];
h[txt] = 0;
}
}
fout << nrs;
closef;
return 0;
}