这个题根本不用建树,因为是完全二叉树,可以把这个想成二进制。对于根是二进制数的首位,之后依次类推。到最后的叶子节点就是从0到pow(2,n)-1。

关键在于在第一次输入的不是按照x1,x2,x3,x4这样的顺序输入的,那么我们就默认他的输入时按从二进制高位到地位。对于查询是按x1,x2,x3,x4这样的顺序。所以不能直接对应,需要一些小的操作来让查询的输入和二进制对的上。

 #include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <stack>
#include <queue>
using namespace std;
const double Pi=3.14159265358979323846;
typedef long long ll;
const int MAXN=+;
const int dx[]={,,,,-};
const int dy[]={,-,,,};
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll mod=1e9+; int main()
{
int n;int cn=;
while(cin>>n&&n)
{
string str[];
for(int i=;i<=n;i++)
cin>>str[i];
string a; cin>>a;//从0开始的到pow(2,n)-1,
int m;cin>>m;
vector <char> V;
for(int i=;i<=m;i++)
{
string s;cin>>s;//输入每个序列
int cnt=; //在树中的位置
for(int i=;i<=n;i++)
{
cnt=cnt*+(s[str[i][]-''-]-'');
}
V.push_back(a[cnt]);
}
printf("S-Tree #%d:\n",cn++);
for(int i=;i<V.size();i++)
cout <<V[i];
cout <<endl<<endl;
}
return ;
}

最新文章

  1. json学习系列(8)JSON与JAVA数据的相互转换实例
  2. spring data mongodb中,如果对象中的属性不想加入到数据库字段中
  3. java float、double精度研究(转)
  4. TEXT文本编辑框4 点击按钮读取文本框内容到内表
  5. 管道实现进程间通讯 、WaitNamedPipe
  6. Chapter 5 Blood Type——12
  7. 将ipad作为电脑拓展屏或分屏的简单方法
  8. Pytorch自定义dataloader以及在迭代过程中返回image的name
  9. java黑魔法-反射机制-02-通过Java反射调用其他类方法
  10. python 回溯法 子集树模板 系列 —— 8、图的遍历
  11. angularjs也支持script形式的template
  12. 【转】float类型在内存中的表示
  13. HDU 6199 2017沈阳网络赛 DP
  14. GDAL读取影像并插值
  15. The Tao Of Programming翻译
  16. C#批量入库
  17. Luogu-3250 [HNOI2016]网络
  18. ABAP术语-Call Transaction
  19. Python \xd7\xaa\xd5\xbdOTT TV\xb1\xa6\xbd\xe0 编码
  20. SD卡给MCU升级

热门文章

  1. python数据可视化
  2. weka安装&amp;配置&amp;使用
  3. linux下用户操作
  4. Tensorflow搭建卷积神经网络识别手写英语字母
  5. Flex 弹性盒基本语法
  6. Saiku控制页面展示的数据过长自动换行(二十四)
  7. c# 关于Threading.ApartmentState
  8. Spark Streaming的容错和数据无丢失机制
  9. my goal
  10. Java——继承的运行顺序