比赛 |
CSP2022普及组 |
评测结果 |
AAWAWWWWWWEEEEEEEEEE |
题目名称 |
逻辑表达式 |
最终得分 |
15 |
用户昵称 |
此账号已注销 |
运行时间 |
1.885 s |
代码语言 |
C++ |
内存使用 |
3.12 MiB |
提交时间 |
2022-10-29 15:45:17 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
char a[100000];
int b[100000],bi=0,b1[10000],b1i=1,b1Max=0,b2Max=0;
int main(){
freopen("csp2022pj_expr.in","r",stdin);
freopen("csp2022pj_expr.out","w",stdout);
cin>>a;
for(int i=0; i<strlen(a); i++)
{
if( a[i] != '(' && a[i] != ')')
{
b[i] = a[i];
bi++;
if(b[i] == '&')
{
b1[b1i] = 1;
b1i++;
}
}
}
if(bi == 3)
{
if(b[1] == '&')
{
if(b[0] == '0')
{
b1Max++;
cout<<0<<endl<<b1Max<<" "<<b2Max;
}
else
{
if(b[2] == '1') cout<<1<<endl<<0<<" "<<0;
else cout<<0<<endl<<0<<" "<<0;
}
}
if(b[1] == '|')
{
if(b[0] == '1')
{
b2Max++;
cout<<1<<endl<<b1Max<<" "<<b2Max;
}
else
{
if(b[2] == '1') cout<<1<<endl<<0<<" "<<0;
else cout<<0<<endl<<0<<" "<<0;
}
}
}
else
{
if(b[1] == '|' && b[3] == '|')
{
if(b[4] == '1') cout<<1<<endl<<0<<" "<<1;
else if(b[0] == '1') cout<<1<<endl<<0<<" "<<1;
else if(b[2] == '1')cout<<1<<endl<<0<<" "<<0;
else cout<<0<<endl<<0<<" "<<0;
}
if(b[1] == '|' && b[3] == '&')
{
if(b[0] == '1') cout<<1<<endl<<0<<" "<<1;
else if(b[2] == '0') cout<<0<<endl<<1<<" "<<0;
else if(b[4] == '1')cout<<1<<endl<<0<<" "<<0;
else cout<<0<<endl<<0<<" "<<0;
}
if(b[1] == '&' && b[3] == '|')
{
if(b[4] == '1') cout<<1<<endl<<0<<" "<<1;
else if(b[0] == '0') cout<<0<<endl<<1<<" "<<0;
else if(b[2] == '1')cout<<1<<endl<<0<<" "<<0;
else cout<<0<<endl<<0<<" "<<0;
}
if(b[1] == '&' && b[3] == '&')
{
if(b[4] == '0') cout<<0<<endl<<1<<" "<<0;
else if(b[0] == '0') cout<<0<<endl<<1<<" "<<0;
else if(b[2] == '1')cout<<1<<endl<<0<<" "<<0;
else cout<<0<<endl<<0<<" "<<0;
}
}
}