Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CHALLENGE: ACCEPTED
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <string>
- #define ll long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- int n;
- cin >> n;
- string s;
- cin >> s;
- int big[n], small[n];
- for (int i = 0;i < n;i++) {
- big[i] = 0;
- small[i] = 0;
- }
- int cnt = 1;
- for (int i = 0;i < n - 1;i++) {
- if (s[i] == '<') big[i] = cnt++;
- }
- big[n - 1] = cnt++;
- for (int i = n - 2; i >= 0;i --) {
- if (s[i] == '>') big[i] = cnt++;
- }
- cnt = n;
- for (int i = 0;i < n - 1;i++) {
- if (s[i] == '>') small[i] = cnt--;
- }
- if (s[n - 2] == '>') small[n - 1] = cnt--;
- cnt = 1;
- for (int i = n - 2; i >= 0;i --) {
- if (s[i] == '>') {
- for (int j = i + 1;j < n - 1;j++) {
- if (s[j] != '<') break;
- small[j] = cnt++;
- }
- }
- }
- if (s[0] == '<') {
- for (int j = 0;j < n - 1;j++) {
- if (s[j] != '<') break;
- small[j] = cnt++;
- }
- }
- if (s[n - 2] == '<') small[n - 1] = cnt++;
- for (int i = 0;i < n;i++) cout << small[i] << " ";
- cout << endl;
- for (int i = 0;i < n;i++) cout << big[i] << " ";
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement