fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <iterator>
  5.  
  6. using namespace std;
  7.  
  8. void out(const vector<string>& v)
  9. {
  10. copy(v.begin(), v.end(), ostream_iterator<string>(cout, " "));
  11. }
  12.  
  13. int main() {
  14. string s;
  15. vector<string> v;
  16. while (cin >> s) v.push_back(s);
  17.  
  18. sort(v.begin(), v.end());
  19. out(v);
  20. cout << endl;
  21. cout << binary_search(v.begin(), v.end(), "bba") << endl;
  22. cout << binary_search(v.begin(), v.end(), "aab") << endl;
  23. cout << lower_bound(v.begin(), v.end(), "bba") - v.begin() << ' ';
  24. cout << upper_bound(v.begin(), v.end(), "bba") - v.begin() << endl;
  25. return 0;
  26. }
Success #stdin #stdout 0.02s 2824KB
stdin
bba aaab a b aa abba babbab bbbab bab aba bba
stdout
a aa aaab aba abba b bab babbab bba bba bbbab 
1
0
8 10