Cod sursa(job #2908473)
Utilizator | Serban Andrei andrei_srbn | Data | 3 iunie 2022 17:58:53 |
---|---|---|---|
Problema | Abc2 | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <iostream>
#include <unordered_map>
#include <fstream>
using namespace std;
ifstream fin("abc2.in");
ofstream fout("abc2.out");
unordered_map <string, int > f;
int main()
{
string s, cuv , cuv2;
fin >> s >> cuv;
int n = cuv.size();
int i , ct=0;
for(i=0;i <= s.size()-n+1; i++)
{
cuv2 = s.substr(i, n);
f[cuv2] ++ ;
}
if(f.find(cuv) != f.end())
{
ct += f[cuv];
f[cuv] = 0;
}
while( fin>>cuv )
{
if(f.find(cuv) != f.end())
{
ct += f[cuv];
f[cuv] = 0;
}
}
fout<<ct;
return 0;
}