QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#199129#7514. Clique Challengeucup-team1883Compile Error//C++172.7kb2023-10-03 21:30:362023-10-03 21:30:36

Judging History

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

  • [2023-10-03 21:30:36]
  • 评测
  • [2023-10-03 21:30:36]
  • 提交

answer

#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
using namespace std;

using ll = long long;
using ull = unsigned long long;

#define LOG(f...) fprintf(stderr, f)
#define DBG(f...) printf("%3d: ", __LINE__), printf(f)
// #define DBG(f...) void()
#define all(cont) begin(cont), end(cont)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

template <class T> void read(T &x) {
  char ch; x = 0;
  int f = 1;
  while (isspace(ch = getchar()));
  if (ch == '-') ch = getchar(), f = -1;
  do x = x * 10 + (ch - '0'); while (isdigit(ch = getchar()));
  x *= f;
}
template <class T, class ...A> void read(T &x, A&... args) { read(x); read(args...); }

const int N = 1005;
const int L = 32;

int n, m;
vector<int> G[N];

ll count_clique(vector<int> V) {
  // printf("cc : ");
  // for (int v : V)
  //   printf("%d ", v);
  // puts("");
  if (V.empty()) return 1;
  assert(V.size() <= 32);
  using bs = uint32_t;
  int n = V.size(), n1 = n / 2, n2 = n - n1;
  vector<bs> g(V.size()), inter1(1 << n1), inter2(1 << n2), sum(1 << n1);
  for (int i = 0; i < n; ++i)
    g[i] = 1u << i;
  for (int u = 0; u < n1; ++u)
    for (int _v : G[V[u]]) {
      int v = find(all(V), _v) - V.begin();
      if (v != n) g[u] |= 1u << v, g[v] |= 1u << u;//, printf("edge %d %d\n", u, v);
    }
  inter1[0] = inter2[0] = (1u << n) - 1;
  sum[0] = 1;
  for (int s = 1; s < (1 << n1); ++s) {
    inter1[s] = g[__builtin_ctz(s)] & inter1[s & (s - 1)];
    sum[s] = (inter1[s] & s) == s;
  }
  for (int b = 0; b < n1; ++b)
    for (int i = 0; i < (1 << n1); i += (2 << b))
      for (int j = i; j < i + (1 << b); ++j)
        sum[j + (1 << b)] += sum[j];
  for (int s = 1; s < (1 << n2); ++s)
    inter2[s] = g[__builtin_ctz(s) + n1] & inter2[s & (s - 1)];//, printf("inter2[%d] = %d\n", s, inter2[s]);
  ll ans = 0;
  bs mask1 = (1u << n1) - 1;
  for (int s = 0; s < (1 << n2); ++s)
    if ((inter2[s] & (s << n1)) == (s << n1)) ans += sum[inter2[s] & mask1];//, printf("add %d\n", inter2[s] & mask1);
  // printf("ret %lld\n", ans);
  return ans;
}

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  read(n, m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    read(u, v);
    G[u].push_back(v); G[v].push_back(u);
  }
  vector<int> large;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (G[i].size() <= L) {
      vector<int> V;
      for (int v : G[i])
        if (v >= i) V.push_back(v);
      ans += count_clique(V);
    }
    else large.push_back(i);
  }
  ans += count_clique(large);
  printf("%lld\n", (ans - 1) % 1000000007);
  return 0;
}

Details

answer.code: In function ‘ll count_clique(std::vector<int>)’:
answer.code:45:14: error: ‘uint32_t’ does not name a type
   45 |   using bs = uint32_t;
      |              ^~~~~~~~
answer.code:8:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    7 | #include <cassert>
  +++ |+#include <cstdint>
    8 | using namespace std;
answer.code:47:10: error: ‘bs’ was not declared in this scope; did you mean ‘abs’?
   47 |   vector<bs> g(V.size()), inter1(1 << n1), inter2(1 << n2), sum(1 << n1);
      |          ^~
      |          abs
answer.code:47:12: error: template argument 1 is invalid
   47 |   vector<bs> g(V.size()), inter1(1 << n1), inter2(1 << n2), sum(1 << n1);
      |            ^
answer.code:47:12: error: template argument 2 is invalid
answer.code:49:6: error: invalid types ‘int[int]’ for array subscript
   49 |     g[i] = 1u << i;
      |      ^
answer.code:53:20: error: invalid types ‘int[int]’ for array subscript
   53 |       if (v != n) g[u] |= 1u << v, g[v] |= 1u << u;//, printf("edge %d %d\n", u, v);
      |                    ^
answer.code:53:37: error: invalid types ‘int[int]’ for array subscript
   53 |       if (v != n) g[u] |= 1u << v, g[v] |= 1u << u;//, printf("edge %d %d\n", u, v);
      |                                     ^
answer.code:55:9: error: invalid types ‘int[int]’ for array subscript
   55 |   inter1[0] = inter2[0] = (1u << n) - 1;
      |         ^
answer.code:55:21: error: invalid types ‘int[int]’ for array subscript
   55 |   inter1[0] = inter2[0] = (1u << n) - 1;
      |                     ^
answer.code:56:6: error: invalid types ‘int[int]’ for array subscript
   56 |   sum[0] = 1;
      |      ^
answer.code:58:11: error: invalid types ‘int[int]’ for array subscript
   58 |     inter1[s] = g[__builtin_ctz(s)] & inter1[s & (s - 1)];
      |           ^
answer.code:58:18: error: invalid types ‘int[int]’ for array subscript
   58 |     inter1[s] = g[__builtin_ctz(s)] & inter1[s & (s - 1)];
      |                  ^
answer.code:58:45: error: invalid types ‘int[int]’ for array subscript
   58 |     inter1[s] = g[__builtin_ctz(s)] & inter1[s & (s - 1)];
      |                                             ^
answer.code:59:8: error: invalid types ‘int[int]’ for array subscript
   59 |     sum[s] = (inter1[s] & s) == s;
      |        ^
answer.code:59:21: error: invalid types ‘int[int]’ for array subscript
   59 |     sum[s] = (inter1[s] & s) == s;
      |                     ^
answer.code:64:12: error: invalid types ‘int[int]’ for array subscript
   64 |         sum[j + (1 << b)] += sum[j];
      |            ^
answer.code:64:33: error: invalid types ‘int[int]’ for array subscript
   64 |         sum[j + (1 << b)] += sum[j];
      |                                 ^
answer.code:66:11: error: invalid types ‘int[int]’ for array subscript
   66 |     inter2[s] = g[__builtin_ctz(s) + n1] & inter2[s & (s - 1)];//, printf("inter2[%d] = %d\n", s, inter2[s]);
      |           ^
answer.code:66:18: error: invalid types ‘int[int]’ for array subscript
   66 |     inter2[s] = g[__builtin_ctz(s) + n1] & inter2[s & (s - 1)];//, printf("inter2[%d] = %d\n", s, inter2[s]);
      |                  ^
answer.code:66:50: error: invalid types ‘int[int]’ for array subscript
   66 |     inter2[s] = g[__builtin_ctz(s) + n1] & inter2[s & (s - 1)];//, printf("inter2[%d] = %d\n", s, inter2[s]);
      |                                                  ^
answer.code:68:5: error: expected ‘;’ before ‘mask1’
   68 |   bs mask1 = (1u << n1) - 1;
      |     ^~~~~~
      |     ;
answer.code:70:16: error: invalid types ‘int[int]’ for array subscript
   70 |     if ((inter2[s] & (s << n1)) == (s << n1)) ans += sum[inter2[s] & mask1];//, printf("add %d\n", inter2[s] & mask1);
      |                ^
answer.code:70:64: error: invalid types ‘int[int]’ for array subscript
   70 |     if ((inter2[s] & (s << n1)) == (s << n1)) ans += sum[inter2[s] & mask1];//, printf("add %d\n", inter2[s] & mask1);
      |                                                                ^
answer.code:70:70: error: ‘mask1’ was not declared in this scope
   70 |     if ((inter2[s] & (s << n1)) == (s << n1)) ans += sum[inter2[s] & mask1];//, printf("add %d\n", inter2[s] & mask1);
      |                                                                      ^~~~~