QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#241070#7514. Clique ChallengeszlhcWA 149ms6724kbC++141.6kb2023-11-05 22:45:212023-11-05 22:45:22

Judging History

你现在查看的是最新测评结果

  • [2023-11-05 22:45:22]
  • 评测
  • 测评结果:WA
  • 用时:149ms
  • 内存:6724kb
  • [2023-11-05 22:45:21]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <vector>
#include <assert.h>
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;
        assert(tot <= 44);
        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: 1596kb

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 1604kb

input:

3 3
1 2
1 3
2 3

output:

7

result:

ok single line: '7'

Test #3:

score: 0
Accepted
time: 1ms
memory: 4176kb

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: 149ms
memory: 6724kb

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:

6621318

result:

wrong answer 1st lines differ - expected: '6621319', found: '6621318'