QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#283513#7514. Clique Challengelight_ink_dots#WA 0ms5544kbC++142.7kb2023-12-14 18:38:312023-12-14 18:38:31

Judging History

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

  • [2023-12-14 18:38:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5544kb
  • [2023-12-14 18:38:31]
  • 提交

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 solve(vector<int>a){
    // cout<<a.size()<<endl;exit(0);
    memset(id,-1,sizeof(id));
    for(int i=0;i<a.size();i++) id[a[i]]=i;
    int b=a.size()/2;
    int num=(a.size()-b);
    if(a.size()!=0){

        cerr<<"?? "<<a.size()<<" "<<b<<endl;
        exit(0);
    }
    memset(s,0,sizeof(int)*(1<<b));
    for(int u=0;u<(1<<num);u++){
        bool fl=0;
        for(int j=0;j<num;j++){
            if(!((u>>j)&1)) continue;
            for(int k=0;k<num;k++){
                if(!((u>>k)&1)) continue;
                if(e[a[b+j]][a[b+k]]==0){fl=1;break;}
            }
            if(fl==1) break;
        }
        if(fl) continue;
        int mask=(1<<b)-1;
        for(int j=0;j<num;j++){
            if(!((u>>j)&1)) continue;
            int z=0;
            for(int k=0;k<b;k++){
                if(e[a[k]][a[b+j]]) z|=(1<<k);
            }
            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;
        for(int i=0;i<b;i++){
            if(!((u>>i)&1)) continue;
            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(fl) continue;
        ans+=s[u];ans%=mod;
    }

    return ans%mod;
    // for(int i=0;i<b;i++){
        
    // }
    // for(int i=b;i<a.size();i++){
        
    // }
}
int n,m;
struct e{
    int x,y;
}d[10000];int deg[3020];
int sol(vector<int>a){
    if(a.empty()){
        return 1;
    }
    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();
    // cerr<<"?? "<<z<<" "<<tmp.size()<<endl;
    int cur=solve(tmp);
    // cerr<<"done"<<endl;
    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;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 5544kb

input:

3 2
1 2
2 3

output:


result:

wrong answer 1st lines differ - expected: '5', found: ''