#include // std::string #include // std::cout #include #include #include #include #include using namespace std; int n; int m; int t; string GetFullName(vector persons, string name) { for(int i=0; i> n; ss >> m; // get persons vector persons; string s; for(int i=0; i> t; map > counters; vector status; for(int i=0; i<=n; i++) { status.push_back(0); //queue qs; //counters.insert(make_pair(i, qs)); } for(int k=0; k> id; if (id >=1 && id <= 4) { // read another int ops >> x; if (id == 1) { // change status : open/close if (status[x] == 1) status[x]=0; else status[x]=1; if (status[x] == 0) { // empty the queue while(!counters[x].empty()) { counters[x].pop(); } } } else if (id == 2) { // read myName string name; ops >> name; string fullName = GetFullName(persons, name); if (status[x] == 1) { counters[x].push(fullName); } } else if (id == 3) { counters[x].pop(); } else if (id == 4) { // print queue if (counters[x].size() == 0) { cout << "-1" << endl; } else { // print queue content, last -> first queue tmpq(counters[x]); vector array; while(!tmpq.empty()) { array.push_back(tmpq.front()); tmpq.pop(); } for(int ai=array.size()-1; ai>=0; ai--) { if (ai != array.size()-1) cout << " "; cout << array[ai]; } cout << endl; } } } else { // case 5 // read myName string name; ops >> name; string fullName = GetFullName(persons, name); int found = 0; for(int i=1; i<=n; i++) { // check in queue i queue tmpq(counters[i]); int firstRun = 0; while(!tmpq.empty()) { if(tmpq.front()==fullName) { found = 1; break; } tmpq.pop(); } if (found) { cout << i; break; } } if (!found) cout << "-1"; cout << endl; } } return 0; }