把freopen关了呀
by 梦游的小雪球 @ 2020-11-25 14:07:57
我试了一下,把freopen关了就有70分了
by 梦游的小雪球 @ 2020-11-25 14:08:59
只是RE了6个点
by 梦游的小雪球 @ 2020-11-25 14:09:31
@[Jr_zLiwen](/user/191281)
by 梦游的小雪球 @ 2020-11-25 14:09:47
你的数组开小了,要开10的6次方
by 梦游的小雪球 @ 2020-11-25 14:11:07
@[Jr_zLiwen](/user/191281) 帮您改了一下
```
#include<bits/stdc++.h>
#define N 1000001
//#define rep(a,b,c) for(register int c=(a);c<=(b);++c)
//#define drep(a,b,c) for(register int c=(a);c>=(b);--c)
using namespace std;
int l[N],x[N],s[N],loc[N],p,n,top;
char c[N];bool jud[N];
struct Tree{int f,l,r;bool v;}t[N];
inline void build()
{
int i=1;
for(int i=1;i<=p;++i)
{
if(l[i]) s[++top]=i,t[i].v=x[l[i]];
else
{
if(c[i]!='!')
{
int x1=s[top--];
int x2=s[top--];
t[x1].f=t[x2].f=i;
t[i].l=x2;t[i].r=x1;
// cout<<t[x1].v<<' '<<t[x2].v<<'\n';
if(c[i]=='|') t[i].v=(t[x1].v||t[x2].v);
else t[i].v=(t[x1].v&&t[x2].v);
}
else
{
int x1=s[top--];
t[i].l=x1;t[x1].f=i;
t[i].v=(!t[x1].v);
}
s[++top]=i;
}
}return;
}
inline void dfs(int i)
{
int L=t[i].l,R=t[i].r;
// cout<<l<<r<<t[i].l<<t[i].r;
// cout<<i<<"-->";
if(!L&&!R)
{
jud[l[i]]=1;
// cout<<l[i];
return;
}
if(c[i]=='&')
{
if(!t[L].v&&!t[R].v){return;}
if(t[L].v&&!t[R].v)dfs(R);
if(t[L].v&&t[R].v)dfs(L),dfs(R);
if(!t[L].v&&t[R].v)dfs(L);
return;
}
if(c[i]=='|')
{
if(t[L].v&&t[R].v)return;
if(!t[L].v&&!t[R].v)dfs(L),dfs(R);
if(!t[L].v&&t[R].v)dfs(R);
if(t[L].v&&!t[R].v)dfs(L);
return;
}
else dfs(L);
return;
}
int main()
{
string in;
while(cin>>in)
{
if(in.length()>1)
{
int res=0;
for(int i=1;i<in.length();++i) res=(res<<1)+(res<<3)+(in[i]^48);
l[++p]=res;loc[res]=p;
}
else c[++p]=in[0];
if(in[0]<='9'&&in[0]>='0'&&in[0]!='x')
{
for(int i=0;i<in.length();++i) n=(n<<1)+(n<<3)+(in[i]^48);
break;
}
}p--;
for(int i=1;i<=n;++i) scanf("%d",&x[i]);
// for(int i=1;i<=n;++i) cout<<x[i];puts("");
int q;cin>>q;build();dfs(p);
for(int i=1;i<=q;++i)
{
int m;scanf("%d",&m);
cout<<(t[p].v^jud[m])<<'\n';
}
return 0;
}
```
by 梦游的小雪球 @ 2020-11-25 14:11:59
@[梦游的小雪球](/user/179601) 谢谢您!!
您太巨辣,谢谢大佬!
by Jr_Zlw @ 2020-11-26 12:56:08
@[Jr_zLiwen](/user/191281) az不用谢(而且我只是个菜鸡,算不上大佬)
by 梦游的小雪球 @ 2020-11-26 13:02:54