第1个点RE第8个点WA 82分求解
  • 板块P1575 正误问题
  • 楼主acb437
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/5/23 22:39
  • 上次更新2023/10/28 00:44:38
查看原帖
第1个点RE第8个点WA 82分求解
520359
acb437楼主2022/5/23 22:39

记录https://www.luogu.com.cn/record/76303907

#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;
bool ans, f, A, o, b, c, d;
int x, y;
string a;
stack <bool> s;
int main()
{
    while(cin >> a)
    {
        if(a == "not")
        {
            if(f)
            {
                f = false;
                continue;
			}
            if(!f)
            {
                f = true;
                continue;
			}
        }
        else if(a == "and")
        {
            A = true;
            x = 0;
            y++;
        }
        else if(a == "or")
        {
            x = 0;
            y++;
        }
        else if(a == "true" && !f)
        {
            s.push(true);
            x++;
            y = 0;
        }
        else if(a == "false" && !f)
        {
            s.push(false);
            x++;
            y = 0;
        }
        else if(a == "true" && f)
        {
            s.push(false);
            f = false;
            x++;
            y = 0;
        }
        else if(a == "false" && f)
        {
            s.push(true);
            f = false;
            x++;
            y = 0;
        }
        if(A && (a == "false" || a == "true"))d = true;
        if(A && d)
        {
            b = s.top();
            s.pop();
            if(s.empty())printf("error");
            c = s.top();
            s.pop();
            s.push(b & c);
            A = false;
            d = false;
        }
        if(x > 1 || y > 1)
        {
            printf("error");
            return 0;
        }
    }
    if(x > 1 || f || s.empty())
    {
        printf("error");
        return 0;
    }
    while(s.size() > 1)
    {
        b = s.top();
        s.pop();
        c = s.top();
        s.pop();
        s.push(b | c);
    }
    if(s.top())
    {
        printf("true");
        return 0;
    }
    printf("false");
    return 0;
}
2022/5/23 22:39
加载中...