QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#295462 | #7514. Clique Challenge | sofija6 | WA | 17ms | 9984kb | C++23 | 2.6kb | 2023-12-31 07:57:59 | 2023-12-31 07:57:59 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define MAXN 1010
#define MAXS (1<<27)
using namespace std;
set<ll> G[MAXN];
bool act[MAXN],dpl[MAXS],dpr[MAXS];
ll sum[MAXS];
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,m,u,v;
cin >> n >> m;
for (ll i=1;i<=m;i++)
{
cin >> u >> v;
G[u].insert(v);
G[v].insert(u);
}
for (ll i=1;i<=n;i++)
act[i]=true;
ll cnt=n,ans=0;
while (cnt)
{
vector<pair<ll,ll> > deg;
for (ll i=1;i<=n;i++)
{
if (act[i])
{
ll c=0;
for (ll next : G[i])
c+=act[next];
deg.push_back({c,i});
}
}
sort(deg.begin(),deg.end());
u=deg[0].second;
act[u]=false;
cnt--;
vector<ll> w,l,r;
for (ll next : G[u])
{
if (act[next])
w.push_back(next);
}
for (ll i=0;i<w.size()/2;i++)
l.push_back(w[i]);
for (ll i=w.size()/2;i<w.size();i++)
r.push_back(w[i]);
for (ll i=0;i<(1<<l.size());i++)
dpl[i]=true;
for (ll i=0;i<(1<<r.size());i++)
{
dpr[i]=true;
sum[i]=0;
}
for (ll i=1;i<(1<<l.size());i++)
{
for (ll j=0;j<l.size();j++)
{
if ((1<<j)&i)
dpl[i]=(dpl[i] && dpl[i^(1<<j)]);
}
}
for (ll i=1;i<(1<<r.size());i++)
{
for (ll j=0;j<r.size();j++)
{
if ((1<<j)&i)
dpr[i]=(dpr[i] && dpr[i^(1<<j)]);
}
}
for (ll i=0;i<(1<<r.size());i++)
sum[i]=dpr[i];
for (ll i=0;i<r.size();i++)
{
for (ll j=0;j<(1<<r.size());j++)
{
if (j&(1<<i))
sum[j]+=sum[j^(1<<i)];
}
}
for (ll i=0;i<(1<<l.size());i++)
{
if (!dpl[i])
continue;
ll mask=(1<<r.size())-1;
for (ll j=0;j<l.size();j++)
{
if ((1<<j)&i)
{
for (ll k=0;k<r.size();k++)
{
if ((1<<k)&mask && !G[l[j]].count(r[k]))
mask^=(1<<k);
}
}
}
ans+=sum[mask];
}
}
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7960kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 2ms
memory: 9984kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: -100
Wrong Answer
time: 17ms
memory: 7740kb
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:
1512
result:
wrong answer 1st lines differ - expected: '1373', found: '1512'