RT,为什么我的代码所有样例(包括大样例)全过,在洛谷上全 TLE?应该也有 30 pts 的啊 qwq
麻烦各位大佬看一下谢谢qwq
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#define ll long long
#define F(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define R(i, a, b) for(int (i) = (a); (i) >= (b); --(i))
using namespace std;
inline int getint() {
int f = 1, x = 0; char c = getchar();
while(!isdigit(c)) {if(c == '-') f = -1; c = getchar();}
while(isdigit(c)) {x = x * 10 + c - '0'; c = getchar();}
return x * f;
}
#define Rint getint()
inline ll getll() {
ll f = 1, x = 0; char c = getchar();
while(!isdigit(c)) {if(c == '-') f = -1; c = getchar();}
while(isdigit(c)) {x = x * 10 + c - '0'; c = getchar();}
return x * f;
}
#define Rll getll()
string s;
int n, q, x, a[100007], len;
void getans() {
stack<int> q;
int cur = 0;
while(cur < len) {
if(s[cur] == 'x') {
cur++;
int num = 0;
while(isdigit(s[cur])) num = num * 10 + s[cur++] - '0';
q.push(a[num]);
cur++;
} else if(s[cur] == '|'){
int x1 = q.top(); q.pop();
int x2 = q.top(); q.pop();
q.push(x1 | x2);
cur += 2;
} else if(s[cur] == '&') {
int x1 = q.top(); q.pop();
int x2 = q.top(); q.pop();
q.push(x1 & x2);
cur += 2;
} else if(s[cur] == '!') {
int x = q.top(); q.pop();
q.push(!x);
cur += 2;
}
}
int ans = q.top();
printf("%d\n", ans);
}
int main() {
getline(cin, s);
len = s.size();
n = Rint;
F(i, 1, n) a[i] = Rint;
q = Rint;
while(q--) {
x = Rint;
a[x] = 1 - a[x];
getans();
a[x] = 1 - a[x];
}
}