Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <queue>
- #include <fstream>
- #include <vector>
- #include <string>
- using namespace std;
- int main()
- {
- ifstream in ("input.txt");
- ofstream out ("output.txt");
- int n, k;
- in >> n >> k;
- vector <queue<int>> vec (n);
- int tmp;
- int tmpe;
- string temp;
- string a;
- for(int i = 0; i < k; i++)
- {
- in >> a;
- if(a[1] == 'U')
- {
- temp = a.substr(a.find('(') + 1, a.find('(') - a.find(',') - 1);
- tmp = atoi(temp.c_str()) - 1;
- temp = a.substr(a.find(',') + 1, a.find(',') - a.find(')') - 1);
- tmpe = atoi(temp.c_str());
- vec[tmp].push(tmpe);
- }
- else if (a[0] == 'T')
- {
- temp = a.substr(a.find('(') + 1, a.find('(') - a.find(',') - 1);
- tmp = atoi(temp.c_str()) - 1;
- out << vec[tmp].front() << " ";
- }
- else if (a[0] == 'P')
- {
- temp = a.substr(a.find('(') + 1, a.find('(') - a.find(',') - 1);
- tmp = atoi(temp.c_str()) - 1;
- out << vec[tmp].front() << " ";
- vec[tmp].pop();
- }
- }
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement