QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#283525 | #7514. Clique Challenge | light_ink_dots | WA | 0ms | 5588kb | C++14 | 2.8kb | 2023-12-14 18:50:11 | 2023-12-14 18:50:11 |
Judging History
answer
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
const int mod=1e9+7;
#define int long long
int s[1<<22];
int id[3000];
vector<int>v[3000];
int e[3000][3000];
int mask[3000],msk[3000];
int solve(vector<int>a){
// cout<<a.size()<<endl;exit(0);
memset(id,-1,sizeof(id));
memset(mask,0,sizeof(mask));
memset(msk,0,sizeof(msk));
for(int i=0;i<a.size();i++) id[a[i]]=i;
int b=a.size()/2;
int num=(a.size()-b);
memset(s,0,sizeof(int)*(1<<b));
// cerr<<"?? "<<num<<" "<<b<<endl;
for(int i=0;i<a.size();i++){
for(int j=0;j<num;j++){
if(e[a[b+j]][a[i]]) mask[i]|=(1<<j);
}
for(int j=0;j<b;j++){
if(e[a[j]][a[i]]) msk[i]|=(1<<j);
}
}
for(int u=0;u<(1<<num);u++){
bool fl=0;
int ma=(1<<num)-1;;
for(int j=0;j<num;j++){
if(!((u>>j)&1)) continue;
ma&=mask[j+b];
}
if((ma&u)!=u) continue;
if(fl) continue;
int mask=(1<<b)-1;
for(int j=0;j<num;j++){
if(!((u>>j)&1)) continue;
int z;
z=msk[j+b];
mask&=z;
}
s[mask]++;
// cerr<<mask<<endl;
}
for(int mid=1;mid<(1<<b);mid<<=1){
for(int j=0;j<(1<<b);j+=(mid<<1)){
for(int k=0;k<mid;k++){
s[j+k]+=s[j+k+mid];
}
}
}
long long ans=0;
for(int u=0;u<(1<<b);u++){
bool fl=0;
int ma=(1<<b)-1;
for(int i=0;i<b;i++){
if(!((u>>i)&1)) continue;
ma&=msk[i];
// for(int j=0;j<b;j++){
// if(!((u>>j)&1)) continue;
// if(e[a[i]][a[j]]==0){fl=1;break;}
// }
// if(fl) break;
}
if((ma&u)!=u) continue;
// if(fl) continue;
ans+=s[u];ans%=mod;
}
return ans%mod;
}
int n,m;
struct e{
int x,y;
}d[10000];int deg[3020];
int sol(vector<int>&a){
if(a.empty()){
return 1;
}
int z=0;deg[0]=1e9;
for(int x:a){
if(deg[z]>deg[x]) z=x;
}
// sort(a.begin(),a.end(),[&](int u,int v){
// return deg[u]>deg[v];
// });
// int z=a.back();
vector<int>tmp;
for(int i=1;i<=n;i++) if(e[i][z]&&i!=z) {
deg[i]--,tmp.push_back(i);
e[i][z]=e[z][i]=0;
}
a.pop_back();
int cur=solve(tmp);
return cur+sol(a);
}
int32_t main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
int x,y;cin>>x>>y;
e[x][y]=e[y][x]=1;
// d[i]=e{x,y};
deg[x]++,deg[y]++;
}
for(int i=1;i<=n;i++) e[i][i]=1;
vector<int>p;
for(int i=1;i<=n;i++) p.push_back(i);
cout<<(sol(p)-1+mod)%mod;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5588kb
input:
3 2 1 2 2 3
output:
4
result:
wrong answer 1st lines differ - expected: '5', found: '4'