博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
virtual oj ACboy needs your help again!
阅读量:6277 次
发布时间:2019-06-22

本文共 1752 字,大约阅读时间需要 5 分钟。

ACboy needs your help again!
 
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit 

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
 
 
#include
int main(){ int m,n,t,i,j,top,f,r; char a[6]; int h[100]; char p[10]; scanf("%d",&t); while(t--) { top=-1; int cut=0; scanf("%d",&m); scanf("%s",p); if(p[2]=='L'){ //栈 for(i=0;i

 

转载于:https://www.cnblogs.com/cniwoq/p/6770995.html

你可能感兴趣的文章
java 图片等比压缩
查看>>
Oracle 创建普通用户,并赋予权限
查看>>
我的友情链接
查看>>
android工程目录结构,及相关文件获取方式(1)
查看>>
Vsftpd内网映射相关原理及配置
查看>>
Linux非对称路由
查看>>
在iOS 8中使用UIAlertController
查看>>
第2课:通过案例对SparkStreaming 透彻理解三板斧之二:解密SparkStreaming运行机制和架构...
查看>>
IOS开发—App 在 IOS 8 的simulator运行时,定位卡死bug解决
查看>>
windows 密钥登陆 linux
查看>>
IOS 录制视频
查看>>
limit检查
查看>>
Android Things 简介
查看>>
菜鸟学Linux 第049篇笔记 DNS log, zone, view
查看>>
菜鸟学Linux 第054篇笔记 建立加密的http
查看>>
ListView 的多选模式
查看>>
宏正自动科技发表新款8/16端口双滑轨LCD KVM多电脑切换器
查看>>
解决 Missing GL version
查看>>
VS 编译链接错误集锦
查看>>
Dns域名服务器之,ACL ,转发域及子域授权的基本配置
查看>>