-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path1105STrees.cpp
More file actions
41 lines (41 loc) · 851 Bytes
/
1105STrees.cpp
File metadata and controls
41 lines (41 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<iostream>
#include<stdio.h>
#include<vector>
#include<limits.h>
#include<string.h>
using namespace std;
int n,m;
int v[7];
char o[10];
char s[1050];
char b[10];
int main()
{
int q=1;
int x;
while(scanf("%d",&n),n){
for(int i=0;i<n;i++){
scanf("%s",b);
x = atoi(b+1);
v[i] = x-1;
}
scanf("%s",s);
//printf("%s\n",s);
scanf("%d",&m);
printf("S-Tree #%d:\n",q++);
for(int i=0;i<m;i++){
scanf("%s",o);
int l=0,r = 1<<n;
int mid;
for(int j=0;j<n;j++){
mid = (l+r)/2;
if(o[v[j]]=='0') r = mid;
else l=mid;
//printf("%d,%d\n",l,r);
}
printf("%c",s[l]);
}
printf("\n\n");
}
return 0;
}