QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#283512#7514. Clique Challengelight_ink_dots#WA 19ms32460kbC++142.4kb2023-12-14 18:33:552023-12-14 18:33:55

Judging History

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

  • [2023-12-14 18:33:55]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:32460kb
  • [2023-12-14 18:33:55]
  • 提交

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){
    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);
    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){
    
    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);
    a.pop_back();
    int cur=solve(tmp);
    return cur+solve(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: 100
Accepted
time: 1ms
memory: 5984kb

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 5656kb

input:

3 3
1 2
1 3
2 3

output:

7

result:

ok single line: '7'

Test #3:

score: -100
Wrong Answer
time: 19ms
memory: 32460kb

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:

1

result:

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