QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#402447 | #7932. AND-OR closure | chy_is_a_fish | Compile Error | / | / | C++14 | 2.8kb | 2024-04-30 16:23:21 | 2024-04-30 16:23:22 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<i64> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
int k = 40;
std::vector g(k, std::vector<int>(k));
std::vector<int> vis(k);
for (int i = 0; i < k; i++) {
i64 v = (1LL << 40) - 1;
int cnt = 0;
for (int j = 0; j < n; j++) {
if (a[j] >> i & 1) {
v &= a[j];
cnt++;
}
}
if (cnt > 0 && cnt < n) {
vis[i] = 1;
for (int j = 0; j < 40; j++) {
if (v >> j & 1) {
g[i][j] = 1;
}
}
}
}
std::vector<int> b;
for (int i = 0; i < k; i++) {
if (!vis[i]) {
continue;
}
int ok = 1;
for (auto j : b) {
if (g[i][j] && g[j][i]) {
ok = 0;
}
}
if (ok) {
b.push_back(i);
}
}
n = b.size();
std::vector<int> t;
std::vector<int> deg(40);
for (auto x : b) {
for (auto y : b) {
if (g[x][y] && x != y) {
deg[y]++;
}
}
}
for (auto x : b) {
if (!deg[x]) {
t.push_back(x);
}
}
for (int i = 0; i < t.size(); i++) {
int x = t[i];
for (auto y : b) {
if (g[x][y] && x != y) {
if (--deg[y] == 0) {
t.push_back(y);
}
}
}
}
assert(t.size() == n);
std::vector<i64> e(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (g[t[i]][t[j]]) {
e[i] |= 1LL << j;
}
}
}
int n1 = n / 2;
int n2 = n - n1;
std::vector<int> f(1 << n2);
for (int s = 0; s < (1 << n2); s++) {
int v = 0;
for (int i = 0; i < n2; i++) {
if (s >> i & 1) {
v |= e[n1 + i] >> n1;
}
}
if (s == v) {
f[s]++;
cerr << s << "\n";
}
}
for (int i = 1; i < (1 << n2); i *= 2) {
for (int j = 0; j < (1 << n2); j += 2 * i) {
for (int k = 0; k < i; k++) {
f[j + k] += f[i + j + k];
}
}
}
i64 ans = 0;
for (int s = 0; s < (1 << n1); s++) {
i64 v = 0;
for (int i = 0; i < n1; i++) {
if (s >> i & 1) {
v |= e[i];
}
}
if (s == (v & ((1 << n1) - 1))) {
ans += f[v >> n1];
}
}
return 0;
}//test
Details
answer.code: In function ‘int main()’: answer.code:18:17: error: missing template arguments before ‘g’ 18 | std::vector g(k, std::vector<int>(k)); | ^ answer.code:34:21: error: ‘g’ was not declared in this scope 34 | g[i][j] = 1; | ^ answer.code:47:17: error: ‘g’ was not declared in this scope 47 | if (g[i][j] && g[j][i]) { | ^ answer.code:61:17: error: ‘g’ was not declared in this scope 61 | if (g[x][y] && x != y) { | ^ answer.code:74:17: error: ‘g’ was not declared in this scope 74 | if (g[x][y] && x != y) { | ^ answer.code:86:17: error: ‘g’ was not declared in this scope 86 | if (g[t[i]][t[j]]) { | ^ answer.code:104:13: error: ‘cerr’ was not declared in this scope; did you mean ‘std::cerr’? 104 | cerr << s << "\n"; | ^~~~ | std::cerr In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:146, from answer.code:1: /usr/include/c++/13/iostream:64:18: note: ‘std::cerr’ declared here 64 | extern ostream cerr; ///< Linked to standard error (unbuffered) | ^~~~