#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 100005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
#define mclr(x,a) memset((x),a,sizeof(x))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-5
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii; inline int rd() {
int x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/
int n; int main()
{
// ios::sync_with_stdio(0);
while (cin >> n) {
stack<int>sk;
queue<int>qu;
priority_queue<int>q;
bool fg1 = 1, fg2 = 1, fg3 = 1;
for (int i = 1; i <= n; i++) {
int opt; opt = rd();
if (opt == 1) {
int x = rd();
if (fg1)sk.push(x);
if (fg2)qu.push(x);
if (fg3)q.push(x);
}
else {
int x = rd();
if (!sk.empty() && sk.top() == x && fg1)sk.pop();
else fg1 = 0;
if (!qu.empty() && qu.front() == x && fg2)qu.pop();
else fg2 = 0;
if (!q.empty() && q.top() == x && fg3)q.pop();
else fg3 = 0;
}
}
int ans = fg1 + fg2 + fg3;
if (!ans)cout << "impossible" << endl;
else {
if (ans == 1) {
if (fg1 == 1)cout << "stack" << endl;
else if (fg2)cout << "queue" << endl;
else if (fg3)cout << "priority queue" << endl;
}
else cout << "not sure" << endl;
}
}
return 0;
}

UVA - 11995 模拟的更多相关文章

  1. UVA - 11995 I Can Guess the Data Structure!(模拟)

    思路:分别定义栈,队列,优先队列(数值大的优先级越高).每次放入的时候,就往分别向三个数据结构中加入这个数:每次取出的时候就检查这个数是否与三个数据结构的第一个数(栈顶,队首),不相等就排除这个数据结 ...

  2. UVA - 11995 - I Can Guess the Data Structure! STL 模拟

    There is a bag-like data structure, supporting two operations: 1 x Throw an element x into the bag. ...

  3. UVa 12100 (模拟) Printer Queue

    用一个队列模拟,还有一个数组cnt记录9个优先级的任务的数量,每次找到当前最大优先级的任务然后出队,并及时更新cnt数组. #include <iostream> #include < ...

  4. uva 10205 模拟

    模拟题 题目描述挺长的.... #include <cstdio> #include <cstdlib> #include <cmath> #include < ...

  5. UVa 11995 I Can Guess the Data Structure!

    做道水题凑凑题量,=_=||. 直接用STL里的queue.stack 和 priority_queue模拟就好了,看看取出的元素是否和输入中的相等,注意在此之前要判断一下是否非空. #include ...

  6. UVa 101 (模拟) The Blocks Problem

    题意: 有n个木块及n个木块堆,初始状态是第i个木块在第i个木块堆上.对应有四种操作,然后输出最终状态. 分析: 用一个vector<int>模拟一个木块堆,进行相应操作即可. #incl ...

  7. [UVA] 11995 - I Can Guess the Data Structure! [STL应用]

    11995 - I Can Guess the Data Structure! Time limit: 1.000 seconds Problem I I Can Guess the Data Str ...

  8. 【每日一题】Flooded! UVA - 815 模拟阅读格式题

    https://cn.vjudge.net/problem/UVA-815 题意:给你一个矩阵,每个格子的数代表一个海拔并且每个格子的面积100平方米.给你整个区域的降水量(立方米),问降水量(米). ...

  9. UVA大模拟代码(白书训练计划1)UVA 401,10010,10361,537,409,10878,10815,644,10115,424,10106,465,10494

    白书一:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=64609#overview 注意UVA没有PE之类的,如果PE了显示WA. UVA ...

随机推荐

  1. 编译错误error:&nbsp;invalid&amp;nbsp…

    昨天遇到一个莫名其妙的编译错误,以前没有见过,而且代码流程看起来也没有太多的奇异之处.后来忍无可忍,百度了下,发现别人也有遇到这个错误的,他的解决方法是:少了"}". 嘿嘿,我开始 ...

  2. PC 微信页面倒计时代码 safari不兼容date的问题

    PC: 1.html页面: <div class="aTime"> <em id="t_d"></em> <em id ...

  3. Python三元运算和lambda表达式

    一.三元运算 1.定义:三元运算是if-else 语句的快捷操作,也被称为条件运算. 2.结构: [on_true]  if  [expression]  else  [on_false] 3.示例: ...

  4. HDR

    [HDR] 什么是 HDR? 高动态范围拍摄(HDR)现在已经得到广泛使用,被用来补偿大多数数码成像传感器有限的动态范围.照片的动态范围是指最暗的色彩与最亮的色彩之间的亮度范围——也可以一并表示色调范 ...

  5. Vue基础以及指令, Vue组件

    Vue基础篇一 Vue指令 Vue的指令directive很像我们所说的自定义属性,指令时Vue模板中最常用的功能,它带有v-前缀,功能是当表达式改变的时候,相应的行为作用在DOM上. <div ...

  6. 【bzoj1787】[Ahoi2008]Meet 紧急集合

    1787: [Ahoi2008]Meet 紧急集合 Time Limit: 20 Sec  Memory Limit: 162 MBSubmit: 2466  Solved: 1117[Submit] ...

  7. Shiro的 rememberMe 功能使用指导(为什么rememberMe设置了没作用?)

    UsernamePasswordToken token = new UsernamePasswordToken(loginForm.getUsername(),loginForm.getPasswor ...

  8. commons-X系列

    1 commons-lang 1.1 ReflectionToStringBuilder 将对象进行字符串拼接 /* * Licensed to the Apache Software Foundat ...

  9. 安装MySQLdb for Python3.7

    Python连接mysql数据库通过MySQLdb模块,在此记录我安装MySQLdb的过程. 一.系统环境 操作系统:Win7 64位 Python:Python 3.7 二.安装说明 A.如果Pyt ...

  10. Python pandas.DataFrame调整列顺序及修改index名

    1. 从字典创建DataFrame >>> import pandas >>> dict_a = {'],'mark_date':['2017-03-07','20 ...