QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#192700 | #7514. Clique Challenge | ucup-team1198# | WA | 28ms | 48752kb | C++20 | 2.4kb | 2023-09-30 15:17:45 | 2023-09-30 15:17:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()
const int MOD = 1e9 + 7;
int add(int a, int b) {
return a + b >= MOD ? a + b - MOD : a + b;
}
const int MAXK = 24;
bitset<(1 << MAXK)> is_clique;
int sum[1 << MAXK], rgh[1 << MAXK];
int16_t ind[1 << MAXK];
int count(vector<int> g) {
int n = g.size();
if (n == 1) return 2;
int m = n / 2;
sum[0] = 1;
for (int mask = 1; mask < (1 << (n - m)); ++mask) {
int i = ind[mask];
sum[mask] = add(sum[mask ^ (1 << i)], sum[mask & (g[i + m] >> m)]);
}
int ans = sum[(1 << (n - m)) - 1];
is_clique[0] = 1;
rgh[0] = (1 << (n - m)) - 1;
for (int mask = 1; mask < (1 << m); ++mask) {
int i = ind[mask];
rgh[mask] = rgh[mask ^ (1 << i)] & (g[i] >> m);
is_clique[mask] = is_clique[mask ^ (1 << i)];
if ((g[i] & mask) != (mask ^ (1 << i))) {
is_clique[mask] = 0;
}
if (is_clique[mask]) {
ans = add(ans, sum[rgh[mask]]);
}
}
return ans;
}
const int MAXN = 1e3 + 100;
int g[MAXN][MAXN];
int deg[MAXN];
int count_ind(vector<int> ind) {
int n = ind.size();
vector<int> g1(n);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (g[ind[i]][ind[j]]) {
g1[i] |= (1 << j);
}
}
}
return count(g1);
}
const int D = 42;
bool is_deleted[MAXN];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for (int i = 1; i < (1 << MAXK); ++i) {
ind[i] = __lg(i ^ (i & (i - 1)));
}
int n, m;
cin >> n >> m;
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
u--; v--;
g[u][v] = g[v][u] = 1;
++deg[u];
++deg[v];
}
int ans = 0;
for (int i = 0; i < n; ++i) {
if (deg[i] <= D) {
vector<int> ind;
for (int j = 0; j < n; ++j) {
if (!is_deleted[j] && g[i][j]) {
ind.push_back(j);
}
}
ans = add(ans, count_ind(ind));
is_deleted[i] = true;
}
}
vector<int> ind;
for (int i = 0; i < n; ++i) {
if (!is_deleted[i]) {
ind.push_back(i);
}
}
ans = add(ans, count_ind(ind));
cout << add(ans, MOD - 1) << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 40412kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 10ms
memory: 40476kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 12ms
memory: 42776kb
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: 28ms
memory: 48752kb
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:
7419594
result:
wrong answer 1st lines differ - expected: '6621319', found: '7419594'