QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#463092 | #8770. Comparator | ucup-team3519 | WA | 57ms | 3812kb | C++20 | 3.6kb | 2024-07-04 13:41:01 | 2024-07-04 13:41:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define V vector
#define all0(x) (x).begin(),(x).end()
#define all1(x) (x).begin()+1,(x).end()
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define cin std::cin
#define cout std::cout
typedef long long LL;
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
//const int MN = 2e5 + 20;//MaxN 记得改一下
const int INF = 2e9 + 1000;//INF
const LL INFLL = 8e18 + 1000;//INF long long
mt19937 mrand(random_device{}());
//模板区域~~~~~~~
//模板结束~~~~~~~
int get_pri (char c) {
if(c == '!') return 5;
if(c == '=') return 4;
if(c == '&') return 3;
if(c == '|') return 2;
if(c == '^') return 1;
assert(0);
}
array<int, 4> cal(array<int, 4> a, array<int, 4> b, char c) {
array<int, 4> ans;
for(int i = 0; i <= 3; i++) {
if(c == '=') ans[i] = a[i] == b[i];
if(c == '&') ans[i] = a[i] && b[i];
if(c == '|') ans[i] = a[i] || b[i];
if(c == '^') ans[i] = a[i] ^ b[i];
if(c == '!') ans[i] = !b[i];
}
return ans;
}
void show(array<int, 4> a) {
cout << "[" << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << "]" << endl;
}
struct node {
char type;
int priority;
bool hav;
array<int, 4> tab;
};
void show (node x){
cout << x.type << " " << x.priority << " " << x.hav << " ";
show(x.tab);
}
array<int, 4> deal(string s) {
int n = s.size() - 1;
V<node> stk;
stk.pb({});
int base = 0;
for(int i = 1; i <= n + 1; i++) {
if(i == n + 1) stk.pb({});
else if(s[i] == '(') base += 10;
else if(s[i] == ')') base -= 10;
else if(s[i] == '1') stk.back().hav = 1, stk.back().tab = {1, 1, 1, 1};
else if(s[i] == '0') stk.back().hav = 1, stk.back().tab = {0, 0, 0, 0};
else if(s[i] == 'x') stk.back().hav = 1, stk.back().tab = {0, 1, 0, 1};
else if(s[i] == 'y') stk.back().hav = 1, stk.back().tab = {0, 0, 1, 1};
else {
stk.pb({s[i], get_pri(s[i]) + base, 0});
}
while(stk.size() >= 3 && stk[stk.size() - 2].priority >= stk[stk.size() - 3].priority
&& stk[stk.size() - 2].priority > stk[stk.size() - 1].priority) {
stk[stk.size() - 3].tab = cal(stk[stk.size() - 3].tab, stk[stk.size() - 2].tab, stk[stk.size() - 2].type);
stk[stk.size() - 2] = stk[stk.size() - 1];
stk.pop_back();
}
}
return stk[0].tab;
}
void solve() {
int k;
k = 10;
V<bitset<1024>> result(1 << k);
for(int i = 0; i < 1 << k; i++) {
for(int j = 0; j < 1 << k; j++) {
result[i][j] = 1;
}
}
// for(int i = 0; i < 1 << k; i++) {
// for(int j = 0; j < 1 << k ;j++) {
// cout << result[i][j] << " \n"[j == (1 << k) - 1];
// }
// }
int a1 = 0;
for(int i = 0; i < 1 << k; i++) if(result[i][i]) a1++;
int a2 = 0;
for(int i = 0; i < 1 << k; i++) {
for(int j = 0; j < 1 << k; j++) {
if(result[i][j] && result[j][i]) a2++;
}
}
int a3 = 0;
for(int i = 0; i < 1 << k; i++) {
for(int j = 0; j < 1 << k; j++) {
// if(!result[i][j]) continue;
auto cur = ~result[i] & result[j];
a3 += cur.count() * (!result[i][j]);
}
}
cout << a1 << " " << a2 << " " << a3 << endl;
}
int32_t main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int tt=1;
//cin >> tt;
while (tt--)
solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 57ms
memory: 3812kb
input:
3 2 1 1 (x=0)&(y=1) 1 1 1 (x=1)&(y=(x^x)) 0 2 2 (x=1)|(y=0) 0 1
output:
1024 1048576 0
result:
wrong answer 1st lines differ - expected: '0 0 0', found: '1024 1048576 0'