Pagini recente » Cod sursa (job #1540000) | Cod sursa (job #2388209) | Cod sursa (job #511488) | Cod sursa (job #269121) | Cod sursa (job #2589026)
#include<bits/stdc++.h>
using namespace std;
ifstream in("abc2.in");
ofstream out("abc2.out");
string text;
int word_length;
unordered_set<string> words;
bool contains(const string& word){
return words.find(word)!=words.end();
}
void read(){
in>>text;
string word;
while(in>>word){
words.insert(word);
}
word_length=word.length();
}
void solve(){
string formed;
int result=0;
for(int i=0;i<text.length();i++){
formed+=text[i];
if(formed.length()==word_length){
if(contains(formed))
result++;
formed=formed.substr(1,word_length-1);
}
}
out<<result<<endl;
}
int main(){
read();
solve();
return 0;
}