QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#672518#7514. Clique ChallengeForever_YoungWA 1ms7980kbC++231.6kb2024-10-24 17:10:002024-10-24 17:10:01

Judging History

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

  • [2024-10-24 17:10:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7980kb
  • [2024-10-24 17:10:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define data dataa
using LL=long long;
using ULL=unsigned long long;
using LD=long double;
#define gcd(x,y) __gcd(unsigned(x),unsigned(y))
const int MOD=int(1e9)+7;
LL msk[100];
int n,m,lk[1010][1010],deg[1010],pos[1010];
int f[1<<25];
int cal(const vector<int>&V)
{
    int n=V.size();
    if(n==0||n==1)return n+1;
    int m=(n+1)/2;
    for(int j=0;j<n;j++)
    {
        msk[j]=1ll<<j;
        for(int i=0;i<n;i++)if(lk[V[j]][V[i]])msk[j]|=1ll<<i;
    }
    for(int i=0;i<(1<<(n-m));i++)
    {
        f[i]=0;
        LL all=(1ll<<n)-1;
        for(int j=0;j<(n-m);j++)
        if((i>>j)&1)
        all&=msk[j+m];
        all>>=m;
        if((all&i)!=i)continue;
        f[i]=1;
    }
    for(int j=0;j<n-m;j++)
    for(int i=0;i<(1<<(n-m));i++)
    if((i>>j)&1)f[i]=(f[i]+f[i^(1<<j)])%MOD;
    int ans=0;
    for(int i=0;i<(1<<m);i++)
    {
        LL all=(1ll<<n)-1;
        for(int j=0;j<m;j++)
        if((i>>j)&1)
        all&=msk[j];
        if((all&i)!=i)continue;
        all>>=m;
        ans=(ans+f[all])%MOD;
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&m);
    rep(i,m){int x,y;scanf("%d%d",&x,&y);lk[x][y]=lk[y][x]=1;deg[x]++;deg[y]++;}
    rep(i,n)pos[i]=i;
    sort(pos+1,pos+n+1,[&](int x,int y){return deg[x]<deg[y];});
    int ans=0;
    rep(i,n)
    {
        int x=pos[i];
        vector<int>V;
        for(int j=i+1;j<=n;j++)if(lk[x][pos[j]])V.pb(j);
        ans=(ans+cal(V))%MOD;
    }
    printf("%d\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5716kb

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 1ms
memory: 6084kb

input:

3 3
1 2
1 3
2 3

output:

7

result:

ok single line: '7'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 7980kb

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:

1100

result:

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