fork(3) download
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4. int main() {
  5. map <string,int> s;
  6. map <string,int> w;
  7. int n, m, a = 0,b = 0;
  8. cin >> n >> m;
  9. string word, sent;
  10. while(cin >> word){
  11. if(word.back() == ',')word.pop_back();
  12. sent = sent + word;
  13. if(word.back() == '.' or word.back() == '?' or word.back() == '!'){
  14. word.pop_back();
  15. sent.pop_back();
  16. if((++s[sent]) == m)a++;
  17. sent = "";
  18. }
  19. if((++w[word]) == n)b++;
  20. }
  21. cout << b << ' ' << a;
  22. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
0 0