2014牡丹江区域赛H(特里)ZOJ3826

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的。字典树的应用

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

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

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

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

时间: 2024-08-30 05:52:31

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

2014牡丹江区域赛H(字典树)ZOJ3826

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 trans

zoj 3827 Information Entropy(2014牡丹江区域赛I题)

Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Information Theory is one of the most popular courses in Marjar University. In this course, there is an important chapter about information entropy. Entropy is t

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

题目链接:ZOJ 3827 Information Entropy 根据题目的公式算吧,那个极限是0 AC代码: #include <stdio.h> #include <string.h> #include <math.h> const double e=exp(1.0); double find(char op[]) { if(op[0]=='b') return 2.0; else if(op[0]=='n') return e; else if(op[0]=='

2014牡丹江 区域赛 Building Fire Stations

给一棵最多2*10^5个结点的树,选择两个结点放置设备,要求所有结点其到最近设备的最远距离最小,求出这个最小距离. 最大值最小,首先想到二分.二分一个最大距离M,先以1号结点bfs出每个结点的深度.任选一个最大深度的结点,则离他距离M的父结点u上必须要放置一个设备.然后再以u进行bfs,同样的选择出第二个结点.再把选择的两个设备结点加入队列bfs,看是否能够遍历所有点,若能就满足. zju上面做的,dfs会栈溢出.第一次以一号结点bfs可以预处理,之后直接取出最大深度的点就行.有可能两次找的放置

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

Description Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics and computer science. It is also known as postfix notation since every operator in an expression follows all of its operands. Bob is a student in

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

Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N rows and M columns. Every day after work, Edward will place

zoj 3822 Domination(2014牡丹江区域赛D题)

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar

zoj 3819(2014牡丹江区域赛 A题 )

题意:给出A班和B班的学生成绩,如果bob(A班的)在B班的话,两个班级的平均分都会涨.求bob成绩可能的最大,最小值. A班成绩平均值(不含BOB)>A班成绩平均值(含BOB) && B班成绩平均值(不含BOB)< B班成绩平均值(含BOB) 化简后得 B班成绩平均值(不含BOB) < X < A班成绩平均值(不含BOB) Sample Input 24 35 5 54 4 36 55 5 4 5 31 3 2 2 1Sample Output 4 42 4 1

2014牡丹江区域赛B(树的直径)ZOJ3820

Building Fire Stations Time Limit: 5 Seconds      Memory Limit: 131072 KB      Special Judge Marjar University is a beautiful and peaceful place. There are N buildings and N - 1 bidirectional roads in the campus. These buildings are connected by road