P1575 True-or-False Problem
Description
Xiao bobo became obsessed with Boolean operations. But after calculating until he got dizzy, he still could not figure it out. He turned to you for help to solve this problem.
Input Format
A string representing a logical expression, containing only `true`, `false`, `or`, `and`, `not`, and spaces (no parentheses and no `xor`). Operator precedence follows Pascal (from high to low: `not`, `and`, `or`), and within the same level evaluate from left to right. If the logical expression is invalid, output `error`.
Output Format
Output one line with the result: `true` or `false`. If the result cannot be determined, output `error`.
Explanation/Hint
For all testdata, the input string length is less than $255$.
For this problem, the results `true`, `false`, and `error` each account for $\dfrac{1}{3}$; "cheating for points" is allowed, but it is not worth it because this is an "easy problem".
---
- $\text{upd 2022.7.21}$: Added $5$ groups of [Hack testdata](https://www.luogu.com.cn/discuss/459823).
Translated by ChatGPT 5