2026-04-29 17:19:53
发布于:浙江
#include<bits/stdc++.h>
using namespace std;
string s;
int ans=0,sum=0,off;
bool val,ed;
int main(){
cin>>s;
for(int i=0;i<s.size();i++){
if(off){
if(s[i]=='('){
int x=1;
while(x){
if(s[i]=='(') x++;
if(s[i]==')') x--;
}
}else if(s[i]=='|'&&off==1) off=0;
else if(s[i]==')') off=0;
else if(s[i]=='&'&&off==1) ans++;
else if(s[i]=='|'&&off==2) sum++;
}else{
if(s[i]=='1') val=1;
if(s[i]=='0') val=0;
if(s[i]=='&'&&val==0){
off=1;
ans++;
}
if(s[i]=='|'&&val==1){
off=2;
sum++;
}
}
}
cout<<val;
cout<<endl<<ans<<" "<<sum;
return 0;
}
这里空空如也


















有帮助,赞一个