I Can Guess the Data Structure!(水题,不过锻炼了stack,queue,priority的用法)
来源:互联网 发布:premiere cs6 mac下载 编辑:程序博客网 时间:2024/05/17 01:22
题意:就是给出一系列的操作和返回值,判断是队列还是优先队列还是栈;
#include <stdio.h>#include <queue>#include <stack> using namespace std;int main(){int n;while (~scanf("%d",&n)){queue<int> que;priority_queue<int> pque;stack<int> tack;int k1=1,k2=1,k3=1;while (n--){int a,b;scanf("%d%d",&a,&b);if (a==1){que.push(b);pque.push(b);tack.push(b);}else {if (!que.empty() && k1){if (que.front()!=b)k1=0;que.pop(); }else k1=0;if (!pque.empty() && k2){if (pque.top()!=b)k2=0;pque.pop(); }else k2=0;if (!tack.empty() && k3){if (tack.top()!=b)k3=0;tack.pop(); }else k3=0;}}if ((k1+k2+k3)>1) printf("not sure\n");else if ((k1+k2+k3)==0) printf("impossible\n");else if (k1==1) printf("queue\n");else if (k2==1) printf("priority queue\n");else printf("stack\n");} return 0;}
- I Can Guess the Data Structure!(水题,不过锻炼了stack,queue,priority的用法)
- UVA11995I Can Guess the Data Structure!(stack + queue + priority_queue)
- UVA - 11995 I Can Guess the Data Structure!(水题)
- 水题(I Can Guess the Data Structure!,UVA 11995)
- I Can Guess the Data Structure! UVA11995
- UVa11995 I Can Guess the Data Structure!
- UVA11995:I Can Guess the Data Structure
- I Can Guess the Data Structure!
- I Can Guess the Data Structure! uva11995
- UVA 11995 I Can Guess the Data Structure!(水题)
- uva 11995 I Can Guess the Data Structure!(STL)
- uva11995 I Can Guess the Data Structure!(基本数据结构)
- UVA11995 I Can Guess the Data Structure!(数据结构,模拟)
- UVA 11995:I Can Guess the Data Structure!(水)
- UVA: I Can Guess the Data Structure!(stl模拟)
- UVA 11995 - I Can Guess the Data Structure! (数据结构) STL的应用
- uva 11995 I Can Guess the Data Structure! (STL的简单应用)
- UVA 11995 I Can Guess the Data Structure! (STL的基本操作)
- C++ 虚函数表解析(写的很好,转过来看看)
- android中常用的弹出提示框
- applet 使用ImageIO.read报错
- Java查看GC情况
- linux2.6.32.2 mini2440平台移植-- ADC 驱动移植
- I Can Guess the Data Structure!(水题,不过锻炼了stack,queue,priority的用法)
- 游戏开发中常用的设计模式
- 一些公式代码(慢慢添加)
- hdu1272小希的迷宫【并差集】
- uva 109 SCUD Busters-AC-Upgraded version
- wp 页面传值
- linux2.6.32.2 mini2440平台移植--LCD 背光驱动
- YALMIP与gurobi安装
- 第十章——维护索引(5)——查找丢失索引