11995 - I Can Guess the Data】的更多相关文章

11995 - I Can Guess the Data Structure! Time limit: 1.000 seconds Problem I I Can Guess the Data Structure! There is a bag-like data structure, supporting two operations: 1 x Throw an element x into the bag. 2 Take out an element from the bag. Given…
I Can Guess the Data Structure! There is a bag-like data structure, supporting two operations: 1 x Throw an element x into the bag. 2 Take out an element from the bag. Given a sequence of operations with return values, you're going to guess the data…
I Can Guess the Data Structure! There is a bag-like data structure, supporting two operations: 1 x Throw an element x into the bag. 2 Take out an element from the bag. Given a sequence of operations with return values, you're going to guess the data…
There is a bag-like data structure, supporting two operations: 1 x Throw an element x into the bag. 2 Take out an element from the bag. Given a sequence of operations with return values, you're going to guess the data structure. It is a stack (Last-I…
题目传送门 题意:训练指南P186 分析:主要为了熟悉STL中的stack,queue,priority_queue,尤其是优先队列从小到大的写法 #include <bits/stdc++.h> using namespace std; int main(void) { int n; while (scanf ("%d", &n) == 1) { stack<int> sta; queue<int> que; priority_queue&…
做道水题凑凑题量,=_=||. 直接用STL里的queue.stack 和 priority_queue模拟就好了,看看取出的元素是否和输入中的相等,注意在此之前要判断一下是否非空. #include <bits/stdc++.h> using namespace std; void scan( int &x ) { char c; ' ); x = c - '; + c - '; } + ; int t[maxn], d[maxn]; bool is_queue(int n) { q…
题意:给你n个操做,判断是那种数据结构. #include<iostream> #include<cstdio> #include<cstdlib> #include<stack> #include<queue> using namespace std; int n; ],u[]; int ck_q() { //cout<<"!!"<<endl; queue<int>s; ; i<n;…
思路:分别定义栈,队列,优先队列(数值大的优先级越高).每次放入的时候,就往分别向三个数据结构中加入这个数:每次取出的时候就检查这个数是否与三个数据结构的第一个数(栈顶,队首),不相等就排除这个数据结构,可以用三个标志变量来标志可能的数据结构. 注意:可能会出现数据结构为空的情况,要先判断非空才能取元素. AC代码 #include <stdio.h> #include <stack> #include <queue> using namespace std; //分别…
大意:猜数据结构是栈.队列或者优先队列,可能为两种以上,也可能都不是. 水题.. STL 记得判断是否为空 #include<iostream> #include<cstdio> #include<stack> #include<queue> using namespace std; const int MAXN=1000+24; int num[MAXN],action[MAXN],n; bool check_stack() { stack<int&…
最近在复习数据结构,发现这套题不错,题目质量好,覆盖广,Data Structures部分包括Example,以及简单,中等,难三个部分,这几天把Example的做完了, 摘要如下: 通过这几题让我复习和练习了优先队列,并查集,并查集的路径压缩. 总结如下: 11995 - I Can Guess the Data Structure! 给出push,pop操作对应的序列,判定是stack, queue还是deque. 用上面三个数据结构对应模拟下push,pop的操作,将结果与输出进行比对,需…