fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. bool is_strelka(string s) {
  6. if (s == ">>-->" || s == "<--<<") {
  7. return true;
  8. }
  9.  
  10. return false;
  11. }
  12.  
  13. int main() {
  14. ios::sync_with_stdio(false);
  15. cin.tie(0);
  16.  
  17. string s;
  18. cin >> s;
  19.  
  20. if (s.length() < 5) {
  21. cout << 0;
  22. return 0;
  23. }
  24.  
  25. int res = 0;
  26.  
  27. for (int i = 0; i < s.length() - 4; i++) {
  28. if (is_strelka(s.substr(i, 5))) {
  29. res++;
  30. }
  31. }
  32.  
  33. cout << res;
  34.  
  35.  
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0.01s 5280KB
stdin
<<<<>>--><--<<--<<>>>--><<<<<<<<<>>--><--<<--<<>>>--><<<<<<<<<>>--><--<<--<<>>>--><<<<<<<<<>>--><--<<--<<>>>--><<<<<<<<<>>--><--<<--<<>>>--><<<<<<<<<>>--><--<<--<<>>>--><<<<<<<<<>>--><--<<--<<>>>--><<<<<<<<<>>--><--<<--<<>>>--><<<<<
stdout
32