Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve()
- {
- ll q;
- cin>>q;
- while(q--)
- {
- string s;
- cin>>s;
- deque<int>dq;
- if(s=="toFront")
- {
- int n;
- cin>>n;
- dq.push_front(n);
- }
- else if(s=="push_back")
- {
- int m;
- cin>>m;
- dq.push_back(m);
- }
- else
- {
- if(s=="front"&&!dq.empty())
- {
- cout<<dq.front()<<nl;
- dq.pop_front();
- }
- else if(s=="back"&&!dq.empty())
- {
- cout<<dq.back()<<nl;
- dq.pop_back();
- }
- else if((s=="back"||s=="front")&&dq.empty())
- {
- cout<<"No job for Ada?"<<nl;
- }
- else if(s=="reverse")
- {
- reverse(all(dq));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement