ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201551 | #3495. expr | hjk | 100 | 485ms | 2100kb | C++11 | 645b | 2024-02-01 09:57:06 | 2024-02-01 12:12:15 |
answer
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
ll n;
int main() {
cin>>n;
while(n--) {
string s;
stack<ll> d;
cin>>s;
for(int i=0; i<s.size(); i++) {
if(s[i]>='0'&&s[i]<='9') {
d.push(s[i]-'0');
} else {
if(s[i]=='!') {
ll x=d.top();
d.pop();
d.push(!x);
} else if(s[i]=='&') {
ll a=d.top();
d.pop();
ll b=d.top();
d.pop();
d.push(a&b);
} else {
ll a=d.top();
d.pop();
ll b=d.top();
d.pop();
d.push(a|b);
}
}
}
cout<<d.top()<<endl;
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 38ms
memory: 2096kb
input:
11 1011|10|0|1||01|11|1||100|10||||010|10||11|10|0|000|11|||001|10|||0110|11|||011||101||||000||||00...
output:
1 1 1 1 1 1 1 1 1 1 0
result:
ok 11 lines
Test #2:
score: 10
Accepted
time: 45ms
memory: 2096kb
input:
11 00&01&00&1&&10&11&00&1&&&&0010&&0&&0011&01&&0&10&&&01&10&0&0&1&1&&01&00&00000&00&&11&00&&&01111&1...
output:
0 0 0 0 0 0 0 0 0 0 1
result:
ok 11 lines
Test #3:
score: 10
Accepted
time: 47ms
memory: 2096kb
input:
10 1!1&11&01|10|01|||01&00&!0|0!11&11&!&|01!|1!&&0!11!|000&00||00!|||!&10!&||11|00&|!&!1|10&01&1!|0!...
output:
0 1 1 0 0 1 0 0 0 0
result:
ok 10 lines
Test #4:
score: 10
Accepted
time: 54ms
memory: 2096kb
input:
10 1!0!|00|01|0!0!&&!0!11!&00!&|||110|1!!|00!&1!&|0!10&00||01|11|0110!|!&|||1&0!0!&0&11!01&00||&0!1!...
output:
1 1 1 0 0 1 0 0 0 1
result:
ok 10 lines
Test #5:
score: 10
Accepted
time: 50ms
memory: 2096kb
input:
10 1!0!&10&0!!!|1!1!&&10|00|00|01&01&11|0!|1!&|!|00&01&00|1!!&0!1|1!&0!1!&!!010&00|&|&|00!&00&00|0!|...
output:
1 0 0 0 1 0 0 1 0 1
result:
ok 10 lines
Test #6:
score: 10
Accepted
time: 50ms
memory: 2100kb
input:
10 11|0!!10&10&&!0!1!|!|!0!&11|00||10&11&00!|&!11&00|00|00|&01&11|1&|0!0!00!&!||!!|&!&00|00|0!0!&1!1...
output:
0 1 0 0 1 1 0 1 1 1
result:
ok 10 lines
Test #7:
score: 10
Accepted
time: 54ms
memory: 2096kb
input:
10 1!0!|0&111&10&!10!&&&!&1!10&11|0|0!|!10!|0!||0!0!||111&00&&||!|101&11&&&011!|!10!||!&&0!1!&1!0&&!...
output:
1 0 1 1 0 0 1 1 1 1
result:
ok 10 lines
Test #8:
score: 10
Accepted
time: 51ms
memory: 2100kb
input:
10 01!|0!&010!1||00&00|0&!&0!&11|1!!|!&!1!11|01&&|111!1|0||&001&11&&&11!&!|1!&110!&0|0!|&1!0!01!|&|!...
output:
1 0 1 1 0 1 1 1 0 0
result:
ok 10 lines
Test #9:
score: 10
Accepted
time: 50ms
memory: 2100kb
input:
10 11!&!1!011|11|&0|0!|||1!111|10|&0|!01|00&01&10&001|00|1|&&0!1!&00|10|0|&0!0!|&|&|01!&0!&01!11|11&...
output:
0 0 0 1 1 0 0 1 1 0
result:
ok 10 lines
Test #10:
score: 10
Accepted
time: 46ms
memory: 2100kb
input:
10 11&0!!0!1&!0!0!0|||&111!&|1!0&1&&&10|0!!100|10&11&0!!|!|0!10!|||&1!1|0!1!|&0!01|11&|!&11|11&00&0!...
output:
1 1 0 1 1 1 0 0 0 1
result:
ok 10 lines