QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#423014 | #7514. Clique Challenge | pandapythoner | WA | 2ms | 3768kb | C++17 | 1.7kb | 2024-05-27 20:49:04 | 2024-05-27 20:49:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
const ll inf = 1e18;
mt19937 rnd(234);
const ll mod = 1e9 + 7;
int n, m;
vector<vector<int>> g;
int usdc;
vector<int> usd;
ll solve(vector<int>& a) {
int k = (int)a.size();
if (k == 0) {
return 1;
}
++usdc;
for (auto x : a) {
usd[x] = usdc;
}
int mn_deg = k;
int mni = -1;
for (int i = 0; i < n; i += 1) {
int deg = 0;
int v = a[i];
for (auto to : g[v]) {
if (usd[to] == usdc) {
deg += 1;
}
}
if (deg < mn_deg) {
mn_deg = deg;
mni = i;
}
}
if (mn_deg == k - 1) {
return (1ll << k) % mod;
}
vector<int> b;
int v = a[mni];
for (auto to : g[v]) {
if (usd[to] == usdc) {
b.push_back(to);
}
}
ll rs = solve(b);
a.erase(a.begin() + mni);
rs = (rs + solve(a)) % mod;
return rs;
}
ll solve() {
usd.assign(n, 0);
usdc = 1;
vector<int> a(n);
for (int i = 0; i < n; i += 1) {
a[i] = i;
}
ll rs = solve(a);
return (rs + mod - 1) % mod;
}
int32_t main() {
if (1) {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
cin >> n >> m;
g.assign(n, vector<int>());
for (int i = 0; i < m; i += 1) {
int u, v;
cin >> u >> v;
--u;
--v;
g[u].push_back(v);
g[v].push_back(u);
}
ll rs = solve();
cout << rs << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3768kb
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:
1000
result:
wrong answer 1st lines differ - expected: '1373', found: '1000'