UVA 1995 I can guess the structer
模 拟
/*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
int read(){
int x=,f=;char ch=getchar();
while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
priority_queue<int>q;
stack<int>st;
queue<int>que;
int n;
int x,y;
bool flag_st,flag_qu,flag_pr;
int main(){
/* freopen("qu.in","r",stdin);
freopen("qu.out","w",stdout);*/ while(scanf("%d",&n)!=EOF){
int i,j;
flag_pr=flag_qu=flag_st=;
while(!q.empty()) q.pop();
while(!st.empty()) st.pop();
while(!que.empty()) que.pop();
for(i=;i<=n;i++){
scanf("%d%d",&x,&y);
if(x==){
q.push(y);
st.push(y);
que.push(y);
}
else{
if(q.empty() || q.top()!=y)flag_pr=;
if(st.empty() || st.top()!=y)flag_st=;
if(que.empty() || que.front()!=y)flag_qu=;
if(!q.empty())q.pop();
if(!st.empty()) st.pop();
if(!que.empty()) que.pop();
}
}
int cnt=;
if(flag_st)cnt++; if(flag_pr)cnt++; if(flag_qu)cnt++;
if(cnt>){
printf("not sure\n");
continue;
}
if(flag_st && !flag_pr && !flag_qu)printf("stack\n");
if(!flag_st && !flag_pr && flag_qu)printf("queue\n");
if(!flag_st && flag_pr && !flag_qu)printf("priority queue\n");
if(!flag_st && !flag_pr && !flag_qu)printf("impossible\n");
}
return ;
}
UVA 1995 I can guess the structer的更多相关文章
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
- UVA计数方法练习[3]
UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...
- UVA数学入门训练Round1[6]
UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...
- UVA - 1625 Color Length[序列DP 代价计算技巧]
UVA - 1625 Color Length 白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束 和模拟赛那道环形DP很想,计算这 ...
- UVA - 10375 Choose and divide[唯一分解定理]
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- UVA - 11584 Partitioning by Palindromes[序列DP]
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...
随机推荐
- ORA-00020: maximum number of processes (300) exceeded
SQL> select count(*) from v$session; COUNT(*)---------- 98 SQL> select count(*) from v$process ...
- 分享一款强大的图片查看器插件,手机PC 通吃,功能超级齐全!
一款强大的图片查看器插件,手机PC 通吃,功能超级齐全! 地址:http://photoswipe.com/
- @GetMapping和@PostMapping 和@RequestMapping区别
@GetMapping 用于将HTTP GET请求映射到特定处理程序方法的注释. 具体来说,@GetMapping是一个作为快捷方式的组合注释@RequestMapping(method = Requ ...
- 重装系统后,重新搭建Selenium Server+Firefox环境
摘要:搭建Selenium自动化测试环境其实是非常简单的事情,在态度上我们不要把它当成难事:折腾起来是很愉快的,自然就成功了. 下面把这次安装的过程记录下来,一来是加深印象,二来可以给大家提供参考. ...
- 掌握Spark机器学习库-07-回归分析概述
1)回归与分类算法的区别 回归的预测结果是连续的,分类的预测结果是离散的. 2)spark实现的回归算法有: 3)通过相关系数衡量线性关系的程度
- (1) Jenkins + Subversion + Maven + TestNG - 软件
软件需求 1 Jenkins http://jenkins-ci.org/ 2 Visual SVN Server https://www.visualsvn.com/server/ 3 Tortoi ...
- 为什么jfinal的控制器不用单例模式
先假controller定采用单例模式,通常两种设计方式来存放 HttpServletRequest.HttpServletResponse 等对象,一是利用一个类似于 ActionContext 的 ...
- cal - 显示一个日历
总览 cal [-mjy ] [月份 [年份 ] ] 描述 Cal 显示一个简单的日历.. 如果没有指定参数, 则显示当前月份. 选项如下所列: -m 显示星期一作为一周的第一天.. (缺省为星期日. ...
- mysql 查看存储过程 并导出
查询数据库中的存储过程 select * from mysql.proc where db = dbName and `type` = 'PROCEDURE' show procedure statu ...
- Sql Server cross apply和outer apply
with result as( select t.str from( ' str union all ' str union all ' str union all ' str union all ' ...