Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <queue>
- #include <set>
- #include <map>
- #include <cstdio>
- #include <cstdlib>
- #include <cctype>
- #include <cmath>
- using namespace std;
- typedef long long LL;
- #define FOR(k,a,b) for(int k(a); k < (b); ++k)
- #define REP(k,a) for(int k=0; k < (a); ++k)
- class BadVocabulary {
- public:
- int count(string badPrefix, string badSuffix, string badSubstring, vector <string> vocabulary) {
- int res=vocabulary.size();
- REP(i,vocabulary.size())
- {
- const string& s=vocabulary[i];
- if(s.length() >= badPrefix.length() && s.substr(0,badPrefix.length())==badPrefix)
- continue;
- if(s.length() >= badSuffix.length() && s.substr(s.size()-badSuffix.length(),badSuffix.length())==badSuffix)
- continue;
- if(s.substr(1,s.length()-2).find(badSubstring)!=string::npos )
- continue;
- --res;
- }
- return res;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment