30分求调
查看原帖
30分求调
729053
lileyang123楼主2024/8/14 19:42
#include<bits/stdc++.h>
using namespace std;
string s;
int n,m,v,a[100010],b[100010],x,y;
bool sum;

int main(){
	getline(cin,s);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}cin>>m;
//	for(int i=1;i<=n;i++){
//		a[i]=b[i];
//	}
	while(m--){
		cin>>v;
		b[v]=!b[v];
		stack <int> st; 
		for(int i=0;i<s.size();i++){
			if(s[i]=='x'){
                int num=0;
                int j=i+1; 
                while(s[j]>='0'&&s[j]<='9'){
                    num=num*10+s[j]-'0';
                    j++;
                }
                i=j-1;
                st.push(b[num]);
            }else if(s[i]=='&'){
                int a=st.top(); 
				st.pop();
                int b=st.top(); 
				st.pop();
                int c=a&b;
                st.push(c);
            }else if(s[i]=='|'){
                int a=st.top(); 
				st.pop();
                int b=st.top(); 
				st.pop();
                int c=a|b;
                st.push(c);
            }else if(s[i] == '!'){
                int a=st.top(); 
				st.pop();
                int c=!a;
                st.push(c);
            }
		}
		cout<<st.top()<<endl;
		b[v]=!b[v];
	}
	return 0;
}
2024/8/14 19:42
加载中...