QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#49874 | #3829. Stephen Cook | ckiseki# | Compile Error | / | / | Python3 | 2.4kb | 2022-09-23 18:41:54 | 2022-09-23 18:41:55 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-09-23 18:41:55]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-09-23 18:41:54]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
struct node {
enum {
AND,
OR,
NOT,
VAR
} op;
node *lc, *rc;
static_assert(sizeof(lc) == sizeof(size_t));
bool eval(const vector<bool> &s) const {
switch (op) {
case AND:
return lc->eval(s) and rc->eval(s);
case OR:
return lc->eval(s) or rc->eval(s);
case NOT:
return !lc->eval(s);
case VAR:
return s[reinterpret_cast<size_t>(lc)];
}
}
};
void drop(node *v) {
if (!v) return;
switch (v->op) {
case node::AND:
case node::OR:
drop(v->rc);
case node::NOT:
drop(v->lc);
case node::VAR:
break;
}
delete v;
}
node *parse() {
string s;
getline(cin, s);
stringstream parser(s);
vector<string> toks;
while (parser >> s) toks.push_back(s);
auto solve = [&](auto self, size_t l, size_t r) -> node * {
};
return solve(solve, 0, toks.size());
}
void chmax(int &x, int v) {
x = max(x, v);
}
void chmin(int &x, int v) {
x = min(x, v);
}
int dp[1024][1024];
void gao(int n, node *o) {
memset(dp, 0, sizeof(dp));
for (int s = 0; s < (1 << n); s++) {
vector<bool> S(n);
for (int j = 0; j < n; j++)
S[j] = (s >> j & 1);
dp[(1 << n) - 1][s] = o->eval(S);
}
for (int s = (1 << n) - 2; s >= 0; s--) {
const int turn = __builtin_parity(s);
for (int msk = s; ; msk = (msk - 1) & 1) {
for (int i = 0; i < n; i++) {
if (~s >> i & 1) {
if (turn == 0) {
chmax(dp[s][msk], dp[s | (1 << i)][msk]);
chmax(dp[s][msk], dp[s | (1 << i)][msk | (1 << i)]);
} else {
chmin(dp[s][msk], dp[s | (1 << i)][msk]);
chmin(dp[s][msk], dp[s | (1 << i)][msk | (1 << i)]);
}
}
}
if (msk == 0)
break;
}
}
if (dp[0][0]) {
cout << "Cook\n";
} else {
cout << "Levin\n";
}
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t; cin >> t;
while (t--) {
int n; cin >> n;
cin.ignore();
node *o = parse();
gao(n, o);
drop(o);
}
return 0;
}
Details
File "answer.code", line 2 using namespace std; ^ SyntaxError: invalid syntax