Cod sursa(job #2297066)

Utilizator mircearoataMircea Roata Palade mircearoata Data 5 decembrie 2018 11:41:14
Problema Abc2 Scor 0
Compilator cpp-64 Status done
Runda prega_casi_5.12.2018 Marime 0.85 kb
#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;
char temp[10000001];
char *tmp2;

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 < n; i++)
        temp[i] = ch[i];
    tmp2 = temp;
    for(int i = n; i < len; i++)
    {
        string str(tmp2);
        ans += (dictionary.find(str) != dictionary.end());
        tmp2++;
        temp[i] = ch[i];
    }
    string str(tmp2);
    ans += (dictionary.find(str) != dictionary.end());
    out << ans;
    return 0;
}