QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#330791 | #7514. Clique Challenge | Williamxzh | WA | 1ms | 6048kb | C++14 | 2.1kb | 2024-02-17 19:06:52 | 2024-02-17 19:06:53 |
Judging History
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;}
if(c1[i]) ++ans;
}
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],++ans;
for(int j=0;j<n-m;++j)
if(!((i>>j)&1)) s[i|(1<<j)]+=s[i];
}
//printf("%d ",s[i]);
}
//puts("");
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
printf("%d%c",a[i][j],j==n?'\n':' ');
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;if(c1[i]) 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();
for(int j=i+1;j<=n;++j)
if(e[a[i]][a[j]]) f.push_back(a[j]);
if(!f.size()) continue;
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+n)%mod);
return 0;
}
/*
6 11
1 2
2 3
3 1
2 4
4 5
5 3
3 4
2 5
1 6
6 3
6 5
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5888kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 6048kb
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:
0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 0 0 1 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0 1 1 1 0 0 1 1 1 0 0 ...
result:
wrong answer 1st lines differ - expected: '1373', found: '0 1 1 0 0 1'