HDU 1702 ACboy needs your help again! (模拟栈和队列)

网友投稿 526 2022-10-21

HDU 1702 ACboy needs your help again! (模拟栈和队列)

HDU 1702 ACboy needs your help again! (模拟栈和队列)

ACboy needs your help again!

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5937    Accepted Submission(s): 3105

Problem Description

ACboy was kidnapped!! he miss his mother very much and is very scare now.You can't image how dark the room he was put into is, so poor :(. As a smart ACMer, you want to get ACboy out of the monster's labyrinth.But when you arrive at the gate of the maze, the monste say :" I have heard that you are very clever, but if can't solve my problems, you will die with ACboy." The problems of the monster is shown on the wall: Each problem's first line is a integer N(the number of commands), and a word "FIFO" or "FILO".(you are very happy because you know "FIFO" stands for "First In First Out", and "FILO" means "First In Last Out"). and the following N lines, each line is "IN M" or "OUT", (M represent a integer). and the answer of a problem is a passowrd of a door, so if you want to rescue ACboy, answer the problem carefully!

Input

The input contains multiple test cases. The first line has one integer,represent the number oftest cases. And the input of each subproblem are described above.

Output

For each command "OUT", you should output a integer depend on the word is "FIFO" or "FILO", or a word "None" if you don't have any integer.

Sample Input

44 FIFOIN 1IN 2OUTOUT4 FILOIN 1IN 2OUTOUT5 FIFOIN 1IN 2OUTOUTOUT5 FILOIN 1IN 2OUTIN 3OUT

Sample Output

122112None23

Source

​​2007省赛集训队练习赛(1)​​

Recommend

lcy   |   We have carefully selected several similar problems for you:  ​​1700​​​ ​​1703​​​ ​​1704​​​ ​​1706​​​ ​​1705​​

题解:模拟栈和队列....STL

AC代码

#include#include#include#include#include#includeusing namespace std;int main(){ int T; scanf("%d",&T); while(T--) { int N,tmp; scanf("%d",&N); char str[10]; scanf("%s",str); if(!strcmp(str,"FIFO")) { queue q; for(int i=0;i s; for(int i=0;i

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:软件设计模式学习——介绍SPI
下一篇:基于RuoYi4.0.0的SpringBoot基础权限框架,改造公司信息化系统基础框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~