fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. int N; cin >> N;
  9. string s; cin >> s;
  10. int Q; cin >> Q;
  11.  
  12. int cnt = 0;
  13. for (int i = 0; i + 2 < N; i++) {
  14. if (s.substr(i, 3) == "><>" || s.substr(i, 3) == "<><") cnt++;
  15. }
  16.  
  17. while (Q--) {
  18. int t; cin >> t;
  19. if (t == 1) {
  20. int l, r; cin >> l >> r;
  21. // flip은 물고기 개수에 영향 없음 → 무시
  22. } else {
  23. cout << cnt << "\n";
  24. }
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5292KB
stdin
6
><>><>
6
2
1 4 6
2
1 1 2
1 2 3
2
stdout
2
2
2