QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#330762#7514. Clique ChallengeWilliamxzhWA 1ms5984kbC++141.8kb2024-02-17 18:47:532024-02-17 18:47:53

Judging History

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

  • [2024-02-17 18:47:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5984kb
  • [2024-02-17 18:47:53]
  • 提交

answer

#include <bits/stdc++.h>
#define il inline
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=1005,M=24;
bool c1[1<<M],c2[1<<M];int b[1<<M],s[1<<M];
il ll solve(int n,bool a[N][N]){
    if(n==1) return 1ll;
    if(n==2) return 2ll+1ll*a[1][2];
    int m=(n+1)/2;int S=(1<<m),T=(1<<(n-m)),x,y,z,u,v,w;ll ans=0ll;
    for(int i=0;i<S;++i) b[i]=0;
    for(int i=0;i<T;++i) s[i]=0;
    c1[0]=1;
    for(int i=1;i<S;++i){
        x=(i&-i),y=int(log2(x));
        if(!c1[i-x]){c1[i]=0;continue;}
        c1[i]=1;
        for(int j=0;j<m;++j) if((((i-x)>>j)&1) && !a[y+1][j+1]) {c1[i]=0;break;}
    }
    c2[0]=1;
    for(int i=1;i<T;++i){
        x=(i&-i),y=int(log2(x));
        if(!c2[i-x]){c2[i]=0;continue;}
        c2[i]=1;
        for(int j=0;j<n-m;++j) if((((i-x)>>j)&1) && !a[y+1+m][j+1+m]) {c2[i]=0;break;}
        if(c2[i]){
            ++s[i];
            for(int j=0;j<n-m;++j)
                if(!((i>>j)&1)) s[i|(1<<j)]+=s[i];
        }
    }
    b[0]=T-1;
    for(int i=1;i<S;++i){
        x=(i&-i),y=int(log2(x)),z=0;
        for(int j=0;j<n-m;++j) if(a[y+1][j+1+m]) z|=(1<<j);
        b[i]=b[i-x]&z,ans+=1ll*s[b[i]];
    }
    return ans%mod;
}
int n,m,in[N],a[N];ll ans;bool g[N][N];
bitset<N> e[N];
vector<int> f;
int x,y;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i) scanf("%d%d",&x,&y),++in[x],++in[y],e[x][y]=e[y][x]=1;
    for(int i=1;i<=n;++i) a[i]=i;
    sort(a+1,a+1+n,[](int x,int y){return in[x]<in[y];});
    for(int i=1;i<=n;++i){
        f.clear();f.push_back(a[i]);
        for(int j=i+1;j<=n;++j)
            if(e[a[i]][a[j]]) f.push_back(a[j]);
        x=f.size();
        for(int i=1;i<=x;++i)
            for(int j=i+1;j<=x;++j)
                g[i][j]=g[j][i]=e[f[i-1]][f[j-1]];
        ans+=solve(x,g);
    }
    printf("%lld",ans%mod);
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5984kb

input:

3 2
1 2
2 3

output:

7

result:

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