fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. void solve() {
  6.  
  7. deque<int> nums = {1};
  8.  
  9. int n;
  10.  
  11. cin >> n;
  12.  
  13. string s;
  14.  
  15. cin >> s;
  16.  
  17. for(int i = 2; i <= n; i++) {
  18.  
  19. if(s[i - 2] == '<') {
  20.  
  21. nums.push_front(i);
  22.  
  23. }
  24.  
  25. else if(s[i - 2] == '>') {
  26.  
  27. nums.push_back(i);
  28.  
  29. }
  30.  
  31. }
  32.  
  33. for(auto i: nums) {
  34.  
  35. cout << i << ' ';
  36.  
  37. }
  38.  
  39. cout << endl;
  40.  
  41. }
  42.  
  43. int main() {
  44.  
  45. ios_base::sync_with_stdio(false);
  46. cin.tie(0);
  47.  
  48. int t;
  49.  
  50. cin >> t;
  51.  
  52. while(t--) {
  53.  
  54. solve();
  55.  
  56. }
  57.  
  58. return 0;
  59.  
  60. }
Success #stdin #stdout 0s 5288KB
stdin
5
2
<
5
<<><
2
>
3
<>
7
><>>><
stdout
2 1 
5 3 2 1 4 
1 2 
2 1 3 
7 3 1 2 4 5 6