Cod sursa(job #2661111)

Utilizator Rares5000Baciu Rares Rares5000 Data 21 octombrie 2020 12:41:48
Problema Abc2 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.88 kb
#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;
}