Untitled
unknown
plain_text
a month ago
762 B
4
Indexable
Never
#include <bits/stdc++.h> using namespace std ; #include <algorithm> #define int long long #define For(n) for(int i = 0; i < n; i++) void solve () { string s; while(cin>>s) { deque<string>str; string temp ="";bool b = true; For(s.length()){ if(s[i] == '['){ b = false; i++; } if(s[i] ==']'){ b = true; i++; } while (s[i] != '['&&s[i]!=']'&&i < s.length()){ temp+= s[i++]; }i--; if(b) str.push_back(temp); else str.push_front(temp); temp=""; } for(auto it :str) cout << it ;cout << endl; } } signed main () { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--) { solve(); } return 0; }
Leave a Comment