Advertisement
niromru

Untitled

Nov 5th, 2021
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a[800000];
  8.     int n;
  9.     int curLeft = 399999;
  10.     int curRight = 400001;
  11.     cin >> n;
  12.     string s;
  13.     cin >> s;
  14.     for (int i = 1; i < n; i++) {
  15.         if (s[i - 1] == 'R') {
  16.             a[curRight] = i;
  17.             curRight++;
  18.         } else {
  19.             a[curLeft] = i;
  20.             curLeft--;
  21.         }
  22.     }
  23.     for (int i = curLeft + 1; i < curRight; i++) {
  24.         cout << a[i] << " ";
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement