Cod sursa(job #2588871)

Utilizator AlexBosneag26Bosneag Alexandru AlexBosneag26 Data 25 martie 2020 15:48:01
Problema Abc2 Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <fstream>
#include <string>
#include <unordered_map>

using namespace std;

ifstream in("abc2.in");
ofstream out("abc2.out");

const int N = 10000001, M = 666019;

unordered_map <string, int> umap;

string text, str, str1;

int main()
{
    int lmax;
    getline(in, text);
    while(getline(in, str))
    {
        lmax = str.length();
        umap[str]++;
    }
    int c = 0, st = 0, dr = lmax - 1;
    while(st + lmax - 1 < text.length())
    {
        str1 = text.substr(st, lmax);
        if(umap[str1] != 0)
            c++, umap[str1] = 0;
            st++;
    }
    out << c;
    return 0;
}