QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#329960 | #7514. Clique Challenge | Register_int | WA | 1ms | 5896kb | C++14 | 1.2kb | 2024-02-17 10:02:03 | 2024-02-17 10:02:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e3 + 10;
vector<int> G[MAXN]; int id[MAXN];
ll f[1 << 22], g[1 << 22], h[44];
inline
ll solve(vector<int> &p) {
memset(id, 0xff, sizeof id);
int n = p.size(), l = n >> 1, r = n - l; ll ans = 0;
for (int i = 0; i < n; i++) id[p[i]] = i, h[i] = 1ll << i;
for (int i = 0; i < n; i++) for (int v : G[p[i]]) if (~id[v]) h[i] |= 1ll << id[v];
*f = (1ll << n) - 1, *g = 1;
for (int i = 0; i < l; i++) f[1 << i] = h[i];
for (int i = 1; i < 1 << l; i++) f[i] = f[i & i - 1] & f[i & -i];
for (int i = 1; i < 1 << r; i++) g[i] = g[i & i - 1] + g[h[__builtin_ctz(i) + l] >> l & i & i - 1];
for (int i = 0; i < 1 << l; i++) if ((i & f[i]) == i) ans += g[f[i] >> l];
return ans;
}
int n, m, d[MAXN]; vector<int> p; ll ans;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1, u, v; i <= m; i++) {
scanf("%d%d", &u, &v), d[u]++, d[v]++;
G[u].push_back(v), G[v].push_back(u);
}
for (int u = 1; u <= n; u++) {
p.push_back(u);
for (int v : G[u]) if (d[u] < d[v] || (d[u] == d[v] && u < v)) p.push_back(v);
ans += solve(p), p.clear();
}
printf("%lld", ans);
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5896kb
input:
3 2 1 2 2 3
output:
10
result:
wrong answer 1st lines differ - expected: '5', found: '10'