70分,应该是运算错了,可查不出来!
#include<bits/stdc++.h>
using namespace std;
char A[1000010];
int n,fe,sn[1000010][2];
bool B[100010],C[100010];
struct node {
bool zh;
int num;
} Z[1000010];
int fr() {
char c=getchar();
int h=0,u=1;
while(c<'0'||c>'9') {
if(c=='-') u=-1;
c=getchar();
}
while(c>='0'&&c<='9') {
h=h*10+c-'0';
c=getchar();
}
return h*u;
}
void dfs(int x){
C[x]=0;
if(sn[x][0]==0) return;
dfs(sn[x][0]);
dfs(sn[x][1]);
}
int main() {
freopen("expr20.in","r",stdin);
freopen("expr.out","w",stdout);
gets(A+1);
int len=strlen(A+1),r=0;
n=fr();
fe=n;
for(int i=1; i<=n; i++) {
B[i]=fr();C[i]=1;
}
for(int i=1; i<=len; i++) {
if(A[i]==' ') continue;
if(A[i]=='x') {
i++;
int h=0;
while(A[i]>='0'&&A[i]<='9') {
h=h*10+A[i]-'0';
i++;
}
Z[++r].num=h;Z[r].zh=B[h];
}
else if(A[i]=='&') {i++;
node x=Z[r--],y=Z[r--];
if(x.zh==0) dfs(y.num);
if(y.zh==0) dfs(x.num);
sn[++fe][0]=x.num;
sn[fe][1]=y.num;
x.zh=x.zh & y.zh;
x.num=fe;
Z[++r]=x;
// cout<<x.zh<<endl;
}
else if(A[i]=='|') {i++;
node x=Z[r--],y=Z[r--];
if(x.zh==1) dfs(y.num);
if(y.zh==1) dfs(x.num);
sn[++fe][0]=x.num;
sn[fe][1]=y.num;
x.zh=x.zh | y.zh;
x.num=fe;
Z[++r]=x;
// cout<<x.zh<<endl;
}
else if(A[i]=='!'){i++;
Z[r].zh=!Z[r].zh;
}
}
bool ans=Z[r].zh;
cout<<ans<<endl;
int q=fr();
for(int j=1; j<=q; j++) {
int w=fr();
// if(!C[w]){printf("%d\n",ans);}
// else{printf("%d\n",!ans);}
}
return 0;
}