QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#267625#7514. Clique ChallengeHongzyWA 2ms9952kbC++171.8kb2023-11-27 15:30:182023-11-27 15:30:19

Judging History

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

  • [2023-11-27 15:30:19]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9952kb
  • [2023-11-27 15:30:18]
  • 提交

answer

#include <bits/stdc++.h>
#define pb push_back
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;
using pii = pair<int, int>;
using ll = long long;

const int mod = 1e9 + 7;
const int N = 1005, M = 50;
int n, m, d[N], ord[N];
bool G[N][N], T[M][M];
int o1[M], o2[M], f[1<<22];
int ic1[1<<22], ic2[1<<22];

int main() {
  scanf("%d%d", &n, &m);
  rep(i, 1, m) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u][v] = G[v][u] = true;
    ++ d[u];
    ++ d[v];
  }
  rep(i, 1, n) ord[i] = i;
  sort(ord + 1, ord + n + 1, [&](int x, int y) {
    return d[x] < d[y];
  });
  ll ans = 0;
  rep(i, 1, n) {
    int u = ord[i];
    // printf("[%d]:\n", u);
    vector<int> vec;
    rep(j, i + 1, n) if(G[u][ord[j]]) vec.pb(ord[j]);
    int m = vec.size();
    rep(p, 0, m - 1) rep(q, p + 1, m - 1) T[p][q] = T[q][p] = G[vec[p]][vec[q]];
    rep(p, 0, m - 1) T[p][p] = true;
    // rep(p, 0, m - 1) rep(q, 0, m - 1) printf("%d%c", (int)T[p][q], " \n"[q == m-1]);
    int h = m / 2, h2 = m - h;
    rep(p, 0, m - 1) {
      o1[p] = o2[p] = 0;
      rep(q, 0, h - 1) if(T[p][q]) o1[p] |= 1 << q;
      rep(q, h, m - 1) if(T[p][q]) o2[p] |= 1 << (q-h);
    }
    ic1[0] = ic2[0] = 1;
    rep(s, 1, (1 << h) - 1) {
      ic1[s] = ic1[s & (s-1)] && (o1[__builtin_ctz(s)] & s) == s;
    }
    rep(s, 1, (1 << h2) - 1) {
      ic2[s] = ic2[s & (s-1)] && (o2[h+__builtin_ctz(s)] & s) == s; 
    }
    for(int b = 1; b < (1<<h2); b *= 2)
      rep(s, b, (1<<h2)-1) if(s & b) ic2[s] += ic2[s^b];
    ll r = 0;
    rep(s, 0, (1 << h) - 1) {
      f[s] = s ? (f[s & (s-1)] & o2[__builtin_ctz(s)]) : (1<<h2)-1;
      (r += ic2[f[s]]) %= mod;
    }
    (ans += r) %= mod;
    // printf("ans = %lld\n", r);
  }
  printf("%lld\n", ans);
  return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7980kb

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 2ms
memory: 9952kb

input:

3 3
1 2
1 3
2 3

output:

7

result:

ok single line: '7'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 7992kb

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:

1441

result:

wrong answer 1st lines differ - expected: '1373', found: '1441'