Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- #ifdef ERFANUL007
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- string s;
- while(getline(cin, s)){
- // cout << s << '\n';
- deque< string > ans;
- string temp = "";
- bool isfront = false;
- for(int i=0; i<s.size(); i++){
- if(s[i] == '['){
- if(isfront) ans.push_front(temp);
- else ans.push_back(temp);
- isfront = true;
- temp = "";
- }
- else if(s[i] == ']'){
- if(isfront) ans.push_front(temp);
- else ans.push_back(temp);
- isfront = false;
- temp = "";
- }
- else temp += s[i];
- }
- if(isfront) ans.push_front(temp);
- else ans.push_back(temp);
- while(!ans.empty()){
- cout << ans.front();
- ans.pop_front();
- }
- cout << '\n';
- }
- #ifdef ERFANUL007
- fprintf(stderr, "\n>>> Runtime : %.9fs\n", (double) (clock() - tStart)/CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement