Hierarchical Notation


Time Limit: 2 Seconds      Memory Limit: 131072 KB


In Marjar University, students in College of Computer Science will learn EON (Edward Object Notation), which is a hierarchical data format that uses human-readable text to transmit data
objects consisting of attribute-value pairs. The EON was invented by Edward, the headmaster of Marjar University.

The EON format is a list of key-value pairs separated by comma ",", enclosed by a couple of braces "{" and "}". Each key-value pair has the form of "<key>":"<value>". <key> is a string
consists of alphabets and digits. <value> can be either a string with the same format of <key>, or a nested EON.

To retrieve the data from an EON text, we can search it by using a key. Of course, the key can be in a nested form because the value may be still an EON. In this case, we will use dot
"." to separate different hierarchies of the key.

For example, here is an EON text:

{"headmaster":"Edward","students":{"student01":"Alice","student02":"Bob"}}

  • For the key "headmaster", the value is "Edward".
  • For the key "students", the value is {"student01":"Alice","student02":"Bob"}.
  • For the key "students"."student01", the value is "Alice".

As a student in Marjar University, you are doing your homework now. Please write a program to parse a line of EON and respond to several queries on the EON.

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains an EON text. The number of colons ":" in the string will not exceed 10000 and the length of each key and non-EON value will not exceed 20.

The next line contains an integer Q (0 <= Q <= 1000) indicating the number of queries. Then followed by Q lines, each line is a key for query. The querying
keys are in correct format, but some of them may not exist in the EON text.

The length of each hierarchy of the querying keys will not exceed 20, while the total length of each querying key is not specified. It is guaranteed that the total size of input data
will not exceed 10 MB.

Output

For each test case, output Q lines of values corresponding to the queries. If a key does not exist in the EON text, output "Error!" instead (without quotes).

Sample Input

1
{"hm":"Edward","stu":{"stu01":"Alice","stu02":"Bob"}}
4
"hm"
"stu"
"stu"."stu01"
"students"

Sample Output

"Edward"
{"stu01":"Alice","stu02":"Bob"}
"Alice"
Error!

题意:RT

思路:这题队友A的。字典树的应用

            然后一层一层(左右括号)存的时候用栈即

            直接存全部可能的索引的字典树,然后值为索引相应在原串上的起始和结束位置

            查询的时候直接将索引在字典树上查,然后读出左右位置输出就可以

版权声明:本文博主原创文章,博客,未经同意不得转载。

2014牡丹江区域赛H(特里)ZOJ3826的更多相关文章

  1. The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)

    The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...

  2. 2014 牡丹江区域赛 B D I

    http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=358 The 2014 ACM-ICPC Asia Mudanj ...

  3. ZOJ 3827 Information Entropy (2014牡丹江区域赛)

    题目链接:ZOJ 3827 Information Entropy 依据题目的公式算吧,那个极限是0 AC代码: #include <stdio.h> #include <strin ...

  4. ZOJ 3822 ( 2014牡丹江区域赛D题) (概率dp)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5376 题意:每天往n*m的棋盘上放一颗棋子,求多少天能将棋盘的每行每列都至少有 ...

  5. zoj 3822 Domination(2014牡丹江区域赛D称号)

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  6. ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)

    Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often ...

  7. ACM学习历程——ZOJ 3829 Known Notation (2014牡丹江区域赛K题)(策略,栈)

    Description Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathema ...

  8. zoj 3822 Domination(2014牡丹江区域赛D题) (概率dp)

    3799567 2014-10-14 10:13:59                                                                     Acce ...

  9. ZOJ3827 ACM-ICPC 2014 亚洲区域赛的比赛现场牡丹江I称号 Information Entropy 水的问题

    Information Entropy Time Limit: 2 Seconds      Memory Limit: 131072 KB      Special Judge Informatio ...

随机推荐

  1. Android client和服务器JSP互传中国

    出于兼容性简化.传统中国等多国语言.推荐使用UTF-8编码. 首选.我们期待Android到底应该怎么办: 在发送前,应该对參数值要进行UTF-8编码,我写了一个static的 转换函数.在做发送动作 ...

  2. Android:创建耐磨应用 - 语音操作

    加入语音处理能力(Adding Voice Capabilities) 语音操作为用户体验可穿戴的重要组成部分,它允许用户快速.免提方式来运行操作. Wear它提供了两种类型的语音操作的: 该系统提供 ...

  3. Paypal-Express Checkout快捷支付方式的android端开发心得(二)

    一.前导 上一篇讲的不是非常好,这里再又一次讲一下. Paypal手机支付有2种形式: 1.Mobile Express Checkout,MEC,快捷支付 2.MPL 假设採用MEC支付方式,这样的 ...

  4. 使用AppCompat_v7 21.0.0d的几个兼容问题

    1.实现新的ActionBarDrawerToggle动画 ActionBarDrawerToggle使用最新的AppCompat_v7 21会出现一个非常帅的动画.使用方式在Androidstudi ...

  5. 飞信免费邮件api,飞信界面

    大家都知道飞信是能够免费发送短信的,可是飞信又没有官方的接口,所以无法借用移动的官方接口实现短信的免费发送,可是还是有一些破解的接口能够使用的. GET方法: 提交格式 http://66.zzuob ...

  6. 代理下载android4.4源代码

    前提条件:需要有user, password, 代理人serverip和port(这一切都使自己的软件来完成下一个.例如freegate,它拥有一套可以自己作为一个代理server.创user/pas ...

  7. 移动端 touchmove高频事件与requestAnimationFrame的结合优化

    移动端最高频耗内存的的操作  莫属 touchmove 与scroll事件  两者需要 微观的 优化,使用 requestAnimationFrame性能优化 H5性能优化requestAnimati ...

  8. JavaScript高级编程

             原文地址: http://www.onlamp.com/pub/a/onlamp/2007/07/05/writing-advanced-javascript.html Web应用程 ...

  9. 安装、设置与启动MySql绿色版的方法

    原文:安装.设置与启动MySql绿色版的方法 1.解压 mysql-noinstall-5.1.30-win32.zip(下载地址http://dev.mysql.com/downloads/mysq ...

  10. 一键安装 gitlab7 on rhel6.4 并设置邮件发送

    一键安装 gitlab7 on rhel6.4 并设置邮件发送 世间本无事,庸人自扰之.书归正传,简短节说:gitlab是个好东西,可是安装手冊奇烂.尽管以前对比文档一步一步安装起来gitlab 6. ...