ACboy needs your help again!

Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 36   Accepted Submission(s) : 29

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

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

4
4 FIFO
IN 1
IN 2
OUT
OUT
4 FILO
IN 1
IN 2
OUT
OUT
5 FIFO
IN 1
IN 2
OUT
OUT
OUT
5 FILO
IN 1
IN 2
OUT
IN 3
OUT

Sample Output

1
2
2
1
1
2
None
2
3

Source

2007省赛集训队练习赛(1)
 #include <stdio.h>
#include <stdlib.h>
#include <string.h> int main()
{
int N,FIFO,FILO,b[],i,j,T,sign[],sum;
scanf("%d",&N);
while(N--)
{
scanf("%d%s",&T,sign);
if(strcmp(sign,"FIFO")==)
{
i=;
j=;
while(T--)
{
scanf("%s",sign);
if(strcmp(sign,"IN")==)
{
scanf("%d",&b[i]);
i++;
}
else if(strcmp(sign,"OUT")==)
{
if(i==j)
{
printf("None\n");
continue;
}
printf("%d\n",b[j]);
j++;
} }
}
else if(strcmp(sign,"FILO")==)
{
i=;
j=;
while(T--)
{
scanf("%s",sign);
if(strcmp(sign,"IN")==)
{
scanf("%d",&b[i]);
i++;
}
else if(strcmp(sign,"OUT")==)
{
if(i==)
{
printf("None\n");
continue;
}
i--;
printf("%d\n",b[i]);
}
}
}
}
return ;
}

ACboy needs your help again!的更多相关文章

  1. hdu 1702 ACboy needs your help again!

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1702 ACboy needs your help again! Description ACboy w ...

  2. (hdu step 8.1.1)ACboy needs your help again!(STL中栈和队列的基本使用)

    题目: ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...

  3. hdu 1712 ACboy needs your help

    ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  4. hdu 1712 ACboy needs your help 分组背包

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem ...

  5. hdoj 1702 ACboy needs your help again!【数组模拟+STL实现】

    ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  6. HDU 1712 ACboy needs your help 典型的分组背包

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 ACboy needs your help Time Limit: 1000/1000 MS ( ...

  7. ACboy needs your help(HDU 1712 分组背包入门)

    ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  8. ACboy needs your help again!--hdu1702

    ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  9. 【泛化物品】【HDU1712】【ACboy needs your help】

    ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  10. HDU 1712 ACboy needs your help(包背包)

    HDU 1712 ACboy needs your help(包背包) pid=1712">http://acm.hdu.edu.cn/showproblem.php? pid=171 ...

随机推荐

  1. windows线程池四种情形(win核心读书笔记)

    windows线程池四种情形(win核心读书笔记) Mircosoft从Windows2000引入线程池API,并在Vista后对线程池重新构架,引入新的线程池API.以下所有线程池函数均适用于Vis ...

  2. debian安装后sudo命令不能用的解决方法

    注:转载他人 且试用过了,我的debian版本是debian8.2 64X debian安装完之后发现sudo命令不能用 找了半天发现是没有安装sudo 得了,进入root安包,炸开他,apt-get ...

  3. ERROR Worker: All masters are unresponsive! Giving up

    启动spark的时候发现,主节点(master)上的Master进程还在,子节点(Worker)上的Worker进程自动关闭. 在子节点上查询log发现: ERROR Worker: All mast ...

  4. Java Method Logging with AOP and Annotations

    Sometimes, I want to log (through slf4j and log4j) every execution of a method, seeing what argument ...

  5. USACO 1.5 Prime Palindromes

    Prime Palindromes The number 151 is a prime palindrome because it is both a prime number and a palin ...

  6. RPC学习

    之前有一篇文章,说了RPC的内容: http://www.cnblogs.com/charlesblc/p/6214391.html 如果有一种方式能让我们像调用本地服务一样调用远程服务,而让调用者对 ...

  7. PAT 团体程序设计天梯赛-练习集 L1-023. 输出GPLT

    给定一个长度不超过10000的.仅由英文字母构成的字符串.请将字符重新调整顺序,按“GPLTGPLT....”这样的顺序输出,并忽略其它字符.当然,四种字符(不区分大小写)的个数不一定是一样多的,若某 ...

  8. Xcode-App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.

    在xcode中上报数据时候,logserver一直没有数据,后来发现控制台有一个提示: 找了半天是因为Xcode7禁止明码的HTTP请求,而自己使用的是Xcode7.2.1 解决办法:修改info.p ...

  9. hdu_2825_Wireless Password(AC自动机+状压DP)

    题目链接:hdu_2825_Wireless Password 题意: 给你m个串,问长度为n至少含k个串的字符串有多少个 题解: 设dp[i][j][k]表示考虑到长度为i,第j个自动机的节点,含有 ...

  10. hdu_5585_Less Time, More profit(二分+最大权闭合图)

    题目链接:hdu_5585_Less Time, More profit 题意: 有n个工厂,每建一个工厂要花费vi,需要时间ti,然后有m个商店,每个商店需要在指定的k个工厂中进货,才能盈利,如果其 ...