QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#330846#7514. Clique ChallengeWilliamxzhCompile Error//C++142.2kb2024-02-17 19:50:222024-02-17 19:50:23

Judging History

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

  • [2024-02-17 19:50:23]
  • 评测
  • [2024-02-17 19:50:22]
  • 提交

answer

#pragma GCC optimize("O2,O3,Ofast,inline,unroll-loops")
#pragma GCC target("avx2,sse4")
#include <bits/stdc++.h>
#define il inline
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=1005,M=23;
bool c1[1<<M],c2[1<<M];int t[1<<M],s[1<<M],a[N],b[N],c[N];
il ll solve(int n,bool e[N][N]){
    if(n==1) return 1ll;
    if(n==2) return 2ll+1ll*e[1][2];
    int m=(n+1)/2;int S=(1<<m),T=(1<<(n-m)),x,y,z;ll ans=0ll;
    for(int i=0;i<S;++i) t[i]=0;
    for(int i=0;i<T;++i) s[i]=0;
    for(int i=1;i<=m;++i){
        a[i]=b[i]=0;
        for(int j=1;j<=m;++j) if(e[i][j]) a[i]|=(1<<(j-1));
        for(int j=1;j<=n-m;++j) if(e[i][j+m]) b[i]|=(1<<(j-1));
    }
    for(int i=1;i<=n-m;++i){
        c[i]=0;
        for(int j=1;j<=n-m;++j) if(e[i+m][j+m]) c[i]|=(1<<(j-1));
    }
    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]=((i-x)&a[y+1])==(i-x),ans+=c1[i];
    }
    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]=s[i]=((i-x)&c[y+1])==(i-x),ans+=c2[i];
    }
    for(int j=0;j<n-m;++j) for(int i=1;i<T;++i) if(((i>>j)&1)) s[i]+=s[i^(1<<j)];
    t[0]=T-1;
    for(int i=1;i<S;++i){
        if(!c1[i]) continue;
        x=(i&-i),y=int(log2(x));
        t[i]=t[i-x]&b[y+1],ans+=1ll*s[t[i]];
    }
    return ans%mod;
}
int n,m,in[N],id[N];ll ans;bool g[N][N];
bitset<N> e[N];
vector<int> f;
int x,y;
int main(){
    //freopen("qoj7514_1.in","r",stdin);
    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) id[i]=i;
    sort(id+1,id+1+n,[](int x,int y){return in[x]<in[y];});
    for(int i=1;i<=n;++i){
        f.clear();
        for(int j=i+1;j<=n;++j)
            if(e[id[i]][id[j]]) f.push_back(id[j]);
        if(!f.size()) continue;
        x=f.size();
        for(int i=1;i<=x;++i)
            for(int j=i;j<=x;++j)
                g[i][j]=g[j][i]=e[f[i-1]][f[j-1]];
        ans+=solve(x,g);
    }
    printf("%lld",(ans+n)%mod);
    return 0;
}
/*
6 12
1 2
2 3
3 1
2 4
4 5
5 3
3 4
2 5
1 6
6 3
6 5
6 2

5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
*/

Details

answer.code: In function ‘int main()’:
answer.code:52:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   52 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
answer.code:53:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   53 |     for(int i=1;i<=m;++i) scanf("%d%d",&x,&y),++in[x],++in[y],e[x][y]=e[y][x]=1;
      |                           ~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/queue:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~