Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- #include <string>
- #include <cstdlib>
- #include <deque>
- using namespace std;
- int main()
- {
- int n, k;
- cin >> n >> k;
- vector<deque<int>> Stek(n+1);
- for (int i(0);i < k;i++)
- {
- string s;
- string s0("");
- string s1("");
- cin >> s;
- int a, b;
- int j(0), p, q;
- if (s[0] == 'P')
- if (s[1] == 'O')
- {
- a = s.find('(');
- b = s.find(')');
- s0 = s.substr(a + 1, b - a - 1);
- p = atoi(s0.c_str());
- cout << Stek[p][0] <<" ";
- Stek[p].pop_front();
- if(Stek[p].empty())
- Stek[p].shrink_to_fit();
- }
- else
- {
- a = s.find('(');
- b = s.find(',');
- s0 = s.substr(a+1, b-a-1);
- p = atoi(s0.c_str());
- a = s.find(')');
- s1 = s.substr(b + 1, a - b - 1);
- q = atoi(s1.c_str());
- Stek[p].push_back(q);
- }
- else
- {
- a = s.find('(');
- b = s.find(')');
- s0 = s.substr(a + 1, b - a - 1);
- p = atoi(s0.c_str());
- cout << Stek[p][0] <<" ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement