zoj1061 Web Navigation

Web Navigation 上帝王牌,Web Navigation Description Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you are asked to implement this. The following commands need to be supported: BACK: Push the current page on the top of the forward stack. Pop the page from the top of the backward stack, making it the new current page. If the backward stack is empty, the command is ignored. FORWARD: Push the current page on the top of the backward stack. Pop the page from the top of the forward stack, making it the new current page. If the forward stack is empty, the command is ignored. VISIT : Push the current page on the top of the backward stack, and make the URL specified the new current page. The forward stack is emptied. QUIT: Quit the browser. Assume that the browser initially loads the web page at the URL http://www.acm.org/ Input Input is a sequence of commands. The command keywords BACK, FORWARD, VISIT, and QUIT are all in uppercase. URLs have no whitespace and have at most 70 characters. You may assume that no problem instance requires more than 100 elements in each stack at any time. The end of input is indicated by the QUIT command. Output For each command other than QUIT, print the URL of the current page after the command is executed if the command is not ignored. Otherwise, print "Ignored". The output for each command should be printed on its own line. No output is produced for the QUIT command. Sample Input VISIT http://acm.ashland.edu/ VISIT http://acm.baylor.edu/acmicpc/ BACK BACK BACK FORWARD VISIT http://www.ibm.com/ BACK BACK FORWARD FORWARD FORWARD QUIT Sample Output http://acm.ashland.edu/ http://acm.baylor.edu/acmicpc/ http://acm.ashland.edu/ http://www.acm.org/ Ignored http://acm.ashland.edu/ http://www.ibm.com/ http://acm.ashland.edu/ http://www.acm.org/ http://acm.ashland.edu/ http://www.ibm.com/ Ignored 立即下载
  1. //zoj1061 Web Navigation
  2. //Accepted 1061 C++ 00:00.03 852K
  3. #include <iostream>
  4. #include <string>
  5. #include <cstdio>
  6. using namespace std;
  7.  
  8. void solve()
  9. {
  10.        char t[10],s[101][71]={"http://www.acm.org/"};
  11.        int cnt=1,pos=0;
  12.        while (1){
  13.               cin >> t;
  14.               if (strcmp(t,"QUIT")==0) break;
  15.               if (strcmp(t,"VISIT")==0){
  16.                      pos++;
  17.                      cin >> s[pos];
  18.                      cout << s[pos] << endl;
  19.                      cnt = pos+1;
  20.               }
  21.               if (strcmp(t,"BACK")==0){
  22.                      pos--;
  23.                      if (pos<0) {
  24.                             pos = 0;
  25.                             cout << "Ignored" << endl;
  26.                      }
  27.                      else cout << s[pos] << endl;
  28.               }
  29.               if (strcmp(t,"FORWARD")==0){
  30.                      pos++;
  31.                      if (pos<cnt) cout << s[pos] << endl;
  32.                      else {
  33.                             pos = cnt-1;
  34.                             cout << "Ignored" << endl;
  35.                      }
  36.               }
  37.        }
  38. }
  39.  
  40. int main()
  41. {
  42. #ifdef ONLINE_JUDGE
  43. #else
  44.        freopen("1061.txt","r",stdin);
  45. #endif
  46.        int n;
  47.        while (cin >> n)
  48.               for (int i=0; i<n; ++i){
  49.                      if (i>0) cout << endl;
  50.                      solve();
  51.               }
  52. #ifdef ONLINE_JUDGE
  53. #else
  54.        fclose(stdin);
  55. #endif
  56.        return 0;
  57. } 
ESP32开发环境与微信小程序通信的完整示例 通过搭建稳定的esp32开发环境,实现其与微信小程序间的双向通信,涵盖Wi-Fi连接、数据收发与协议设计,为物联网应用提供低成本解决方案。 阅读详情

相关推荐

PDF.js实现分片加载问题

PDF.js实现分片加载问题。

qq_32822693的博客 4977

Web Navigation(浏览器浏览网页模拟)

问题: 浏览器浏览网页模拟。 VISIT:访问。 BACK:后退。 FORWARD:前进。 QUIT:退出。 Sample Input: VISIT http://acm.ashland.edu/ VISIT http://acm.baylor.edu/acmicpc/ BACK BACK BACK FORWARD VISIT http://www.ibm.com/ BACK BACK FORWA...

weixin_44350170的博客 1673

Ghidra逆向工具入门:从安装到实战分析baby.exe(附详细配置截图)

本文详细介绍了Ghidra逆向工具的安装配置与实战应用,通过破解CTF题目baby.exe的全过程展示其强大功能。从Java环境搭建到插件配置,再到反编译技巧与动态调试方法,帮助读者快速掌握这款免费开源的反编译神器,有效替代收费的IDA Pro工具。

weixin_29252171的博客 352

Web Navigation(Web导航)

【问题描述】标准的网页浏览器包含了对已访问页面进行后退和前进操作。一种实现这些操作的方法就是使用两个栈来保存页面历史使它们能被后退和前进访问到。在这个问题中,你被要求实现这些。以下操作必须支持:BACK: 将向后的栈的栈顶页面弹出,使它成为新的当前页。 假如向后的栈是空的,则这个操作是ignored。FORWARD: 将当前页放进向后的栈的栈顶。将向前的栈的栈顶页面弹出,使它成为新的当前页。假如向

linyq@BambooFan ~ 1394

Redhawk:什么是timing window?

STA timing file中timing window的作用和计算方式

m0_61544122的博客 1万+

【知识分享】IBIS 建模指南 04

文章详细阐述了将缓冲器数据转换为IBIS模型格式的核心步骤与规范要求。主要内容包括:1)IBIS文件三大结构(文件头信息、组件引脚映射、缓冲器行为描述)及其关键词定义;2)四种关键I-V表(上下拉、电源/地钳位)的数据处理规则,强调需避免重复计算效应;3)切换特性描述方法,指出V-T波形表优于Ramp数据的三大优势;4)差分缓冲器通过[DiffPin]关键词实现建模的特殊流程。文中特别强调数据外推校验、参考电压基准转换、工艺角数据排序等易错环节的处理技巧,为创建符合IBIS 4.0规范的精确模型提供指导。

一只豌豆象的博客 2051

1028:Web Navigation:堆栈操作+小坑点分析

题目大意 标准的Web浏览器包含可在最近访问的页面之间前进和后退的功能。 实现这些功能的一种方法是使用两个堆栈来跟踪通过向前和向后移动可以到达的页面。 在此问题中,要求您实施此操作。 需要支持以下命令: BACK:将当前页面推入正向堆栈顶部。 从向后堆栈的顶部弹出页面,使其成为新的当前页面。 如果向后堆栈为空,则忽略该命令。 前进:将当前页面推入后退堆栈的顶部。 从向前堆栈的顶部弹出页面,使其成为...

csyifanZhang的博客 488

各大厂薪资对比爬虫:Python采集OfferShow爆料数据

print(f"⚠️ API返回错误码: {data.get('code')}, msg: {data.get('msg')}")ax.set_title('各大厂薪资对比 (基于OfferShow爆料数据)', fontsize=16, fontweight='bold')stats.columns = ['人数', '平均年薪', '年薪中位数', '年薪标准差', '平均月薪', '平均月数']print(analyzer.get_position_stats('字节跳动').head(10))

2201_76125261的博客 603

web入门——导航栏

本专栏内容代码来自《响应式web(HTML5+CSS3+Bootstrap)》教材,一步步实现网页的导航栏。

阿常的博客 2283

全志V3S嵌入式驱动开发(uboot移植)

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】 安装了ubuntu操作系统,有了开发板,下面就可以进行我们的开发工作了。第一步,我们要面临的问题就是uboot移植。一般来说,嵌入式的基础环境就是uboot、linux和rootfs。uboot完成一些基本硬件的初始化,比如cpu频率设置、ddr初始化、加载linux等等。早前,uboot的烧入比较麻烦,需要jtag工具才能完成。现在来说,很多soc支持系统直接从sd卡启动,这对开发

嵌入式-老费,一个分享专业嵌入式知识的blog 2818

RK3588 固定hdmiin的dev/videoX节点

RK3588 固定hdmiin的dev/videoX节点

目前从事linux驱动开发,多交流多学习吧 2050

zoj 1061 Web Navigation

Web NavigationTime Limit:2 Seconds Memory Limit:65536 KB Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these f...

dengkonglou4529的博客 166

Allegro如何用自带的功能将线段变成铜皮操作指导

在做PCB设计的时候,有时根据设计需要将线段变成铜皮,可以借助辅助工具来实现这一操作,但是Allegro自身也自带这个功能,如下图。勾选Delete original objects。如何用自带的功能将线段变成铜皮操作指导。勾选Convert to shape,需要把这段走线变成铜皮。

weixin_54787054的博客 2946

ZOJ-1061-Web Navigation

简单题。模拟浏览器打开网页的前进后退顺序。这道题的题目有诱使使用两个stack的嫌疑,但其实只用字符串数组和两个游动下标就足够了C++ 00:00.01 400K//1061//C++ 00:00.01 400K #includestdio.h>#includestring.h>char log[102][72];int lognum,cur;int main(){//    fr

outer of the space 1941

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

ZOJ1061 Web Navigation

原始版本:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include iostream>#include stack>#include string>using namespace std;vo

1156

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

zoj1061 Web Navigation (栈——基础练习)

题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=61 题意:模拟网站前进后退的功能。要有俩个栈——一个是back栈,一个是forward栈。 BACK操作:如果(back栈为空) 输出ignore。否则,把当前网页入forward栈,back栈首出栈,打印当前网页; FORWARD操作:如果(forward栈

f1024042400的专栏 642

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

ZOJ-1061-Web Navigation (栈的应用)

Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be re...

qiulianshaonv_wjm的博客 219

UVALive2356 ZOJ1061 Web Navigation【堆栈+模拟】

Web Navigation Time Limit:2 Seconds Memory Limit:65536 KB Standard web browsers contain features to move backward and forward among the pages recently visited. One way to i...

weixin_34413357的博客 199

zoj 1061 &&poj 0128 Web Navigation(STL 栈~~水)

题意: 题目已经说的很清楚了..>_ YY; 啊,真心吐血 啊,第几次忘记清空了。。。。。几次的WA,又浪费时间了...苦逼啊 不过字符串的string一些内容还是学习了 #include #include #include using namespace std; int main() { stacks_f;//前进栈 stacks_b;//后退栈 stri

uiiの技术随笔 741
上一篇: zoj1026 Modular multiplication of polynomials
下一篇: zoj1068 P,MTHBGWB
fairylan
博客等级 码龄21年 2粉丝 33原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值