###### ZOJ 3826 Hierarchical Notation
HASH保存每个KEY对应的值的起始位置和结束位置，最后直接输出就可以了
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
long long mv;
map<long long,pair<long long,long long> > G;
string s;
long long op(char n)
{
if(n>='0'&&n<='9')return n-'0';
else if(n>='A'&&n<='Z')return n-'A'+11;
else if(n>='a'&&n<='z')return n-'a'+45;
else if(n=='.')return 62;
return 63;
}
void dfs(long long n)
{
long long temp=n;
while(s[mv]!='}')
{
mv++;
if(s[mv]=='}')return;
n = temp;
while(s[mv]!=':')n=n*123+op(s[mv++]);
long long left = ++mv;

if(s[mv]=='{')
dfs(n*123+62);
else
while(s[mv+1]!=','&&s[mv+1]!='}')mv++;
G[n] = make_pair(left,mv);
mv++;
}

}
int main()
{
long long T;
cin >> T;
while(T--)
{

cin >> s;
mv = 0;
G.clear();
dfs(0);

long long n;
cin >> n;
while(n--)
{
string str;
cin >> str;
long long nu = 0;
for(int i=0;i<str.length();i++)
{
nu=nu*123+op(str[i]);
}
if(G.count(nu))
{
for(int i = G[nu].first;i<=G[nu].second;i++)
cout<<s[i];
cout<<endl;
}
else
cout<<"Error!"<<endl;
}
}
return 0;
}

#### Hierarchical Notation ZOJ - 3826

2017-11-03 19:35:29

#### ZOJ 3826 Hierarchical Notation

2016-05-24 20:54:46

#### ZOJ 3826 Hierarchical Notation 模拟

2014-10-15 13:21:07

#### zoj 3826 Hierarchical Notation（模拟）

2014-10-15 21:03:56

#### zoj 3826 Hierarchical Notation(模拟)

2014-10-13 09:22:31

#### zoj 3826 Hierarchical Notation(hash+dfs)

2018-01-26 18:29:51

#### ZOJ 3826 Hierarchical Notation（模拟-字符串处理）

2015-09-12 22:16:53

#### ZOJ 3826 Hierarchical Notation(2014 牡丹江 H，字符串模拟)

2014-10-12 17:42:32

#### [2014 Regional]牡丹江 H Hierarchical Notation 做题实录

2014-10-13 13:01:20

#### ZOJ-3826-Hierarchical Notation【哈希】

2015-10-03 15:25:03

## 不良信息举报

ZOJ 3826 Hierarchical Notation