uva - 11995 I Can Guess the Data Structure! Solution
uva - 11995 I Can Guess the Data Structure! #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<queue> #include<vector> #include<functional> #include<stack> using namespace std; int main(){ int arr[3]; stack<int> st; queue<int> q; priority_queue<int> pq; int i, z, n, x, y; while (cin >> n){ arr[0] = arr[1] = arr[2] = 0; while (!st.empty()) st.pop(); while (!q.empty()) q.pop(); while (!pq.empty()) pq.pop(); for (i = 0; i < n; i++){ cin >> x >> y; if (x == 1){ if (arr[0] != 2) st.push(y); if (arr[1] != 2) q.push(y); if (arr[2] != 2) pq.push(y); } else{ if (!q.empty() && arr[1] != 2){ z = q.front(); if (z == y) arr[1] = 1; else arr[1] = 2; q.pop(); } else{ arr[1] = 2; } if (!st.empty() && arr[0] != 2){ z = st.top(); ...