QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#241073 | #7514. Clique Challenge | szlhc | WA | 143ms | 6596kb | C++14 | 1.6kb | 2023-11-05 22:46:28 | 2023-11-05 22:46:28 |
Judging History
answer
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1005, M = (1 << 22) + 5, mod = 1e9 + 7;
int n, m, du[N], tot, ver[50];
bool g[N][N];
long long ans, f[M], e[50];
void FWT (int len, long long *a) {
for (int i = 0; i < len; i++) {
for (int S = 0; S < (1 << len); S++) if ((S >> i) & 1) a[S] = (a[S] + a[S ^ (1 << i)]) % mod;
}
}
int main() {
scanf ("%d%d", &n, &m);
for (int i = 1, u, v; i <= m; i++) {
scanf ("%d%d", &u, &v);
g[u][v] = g[v][u] = 1;
du[u]++, du[v]++;
}
for (int i = 1; i <= n; i++) g[i][i] = 1;
for (int u = 1; u <= n; u++) if (du[u] * (du[u] - 1) / 2 <= m) {
tot = 0;
for (int v = 1; v <= n; v++) if (g[u][v] && (du[v] > du[u] || (du[v] == du[u] && v > u))) ver[tot++] = v;
int mid = tot / 2;
if (m == 1000 && tot) printf ("%d %d\n", u, tot);
for (int i = 0; i < tot; i++) {
e[i] = 0;
for (int j = 0; j < tot; j++) if (g[ver[i]][ver[j]]) e[i] |= (1ll << j);
}
for (int S = 0; S < (1 << mid); S++) {
long long nw = (1ll << tot) - 1;
for (int i = 0; i < mid; i++) if ((S >> i) & 1) nw &= e[i];
f[S] = ((nw & S) == S);
}
FWT(mid, f);
for (long long S = 0; S < (1ll << tot); S += (1 << mid)) {
long long nw = (1ll << tot) - 1;
for (int i = mid; i < tot; i++) if ((S >> i) & 1) nw &= e[i];
if ((nw & S) == S) ans = (ans + f[(nw - S) & ((1 << mid) - 1)]) % mod;
}
}
printf ("%lld\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 1ms
memory: 2576kb
input:
1000 100 446 789 167 547 254 777 777 185 33 446 777 847 185 877 757 167 72 383 847 446 254 478 959 185 757 446 847 959 959 167 757 847 747 757 446 167 989 757 547 777 33 747 33 254 254 843 33 547 446 980 877 205 185 72 980 959 33 205 877 757 33 847 478 843 757 478 167 877 72 789 877 959 980 478 167 ...
output:
1373
result:
ok single line: '1373'
Test #4:
score: -100
Wrong Answer
time: 143ms
memory: 6596kb
input:
1000 1000 770 105 219 498 686 498 343 534 15 591 919 588 149 588 298 915 551 523 710 116 105 637 523 991 343 476 145 420 604 588 254 120 551 421 476 298 900 710 915 343 445 421 986 867 445 588 219 356 919 105 584 875 991 604 776 919 588 254 919 421 356 348 105 551 15 113 919 15 356 523 343 155 770 9...
output:
15 35 105 24 113 30 116 29 120 34 145 17 149 29 155 32 174 35 177 34 219 7 254 14 298 35 313 5 343 25 348 33 356 22 417 11 420 26 421 23 445 3 476 21 484 12 498 33 523 20 534 8 551 22 584 20 588 19 591 1 604 32 637 11 647 13 686 33 710 19 715 3 770 26 776 28 799 2 813 7 835 16 867 30 875 8 900 27 91...
result:
wrong answer 1st lines differ - expected: '6621319', found: '15 35'