QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546741 | #7514. Clique Challenge | Yoralen | ML | 1ms | 6036kb | C++14 | 1.2kb | 2024-09-04 12:48:29 | 2024-09-04 12:48:29 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define int long long
const int H=(1<<19)+5,mod=1e9+7,N=1000;
int f[H],R,Lim,vis[H];
int st[N],id[N],n,m,du[N];
struct node{int x,y;}a[N];
vector<int>G[N],V[N];
int inc(int a,int b){a+=b;return a>=mod?a-mod:a;}
int DP(int S){
if(!S)return 1;
if(S<=R&&vis[S])return f[S];
int it=0,I;
for(I=40;I>=0;I--){
if((S>>I)&1){it=I;break;}
}
int v1=DP(S^(1ll<<it));
int s=0,u=st[it];
for(int e:G[u]){
if(id[e]!=-1)s|=(1<<id[e]);
}
int v2=DP(S&s);
if(S<=R)f[S]=inc(v1,v2),vis[S]=1;
return inc(v1,v2);
}
signed main(){
int i,j;
scanf("%lld%lld",&n,&m);
for(i=1;i<=m;i++){
scanf("%lld%lld",&a[i].x,&a[i].y);
du[a[i].x]++;du[a[i].y]++;
G[a[i].x].push_back(a[i].y);
G[a[i].y].push_back(a[i].x);
}
for(i=1;i<=m;i++){
if(du[a[i].x]<du[a[i].y]||(du[a[i].x]==du[a[i].y]&&a[i].x<a[i].y)){
V[a[i].x].push_back(a[i].y);
}
else V[a[i].y].push_back(a[i].x);
}
int ans=0;
for(i=1;i<=n;i++){
int c=0;
for(j=1;j<=n;j++)id[j]=-1,st[c]=0;
for(int e:V[i]){id[e]=c;st[c]=e;c++;}
Lim=(1<<c)-1,R=(1<<(c/2))-1;
for(j=0;j<=R;j++)f[j]=vis[j]=0;
ans=inc(ans,DP(Lim));
}
printf("%lld",ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5884kb
input:
3 2 1 2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 1ms
memory: 6024kb
input:
3 3 1 2 1 3 2 3
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 1ms
memory: 6036kb
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:
1373
result:
ok single line: '1373'
Test #4:
score: -100
Memory Limit Exceeded
input:
1000 1000 770 105 219 498 686 498 343 534 15 591 919 588 149 588 298 915 551 523 710 116 105 637 523 991 343 476 145 420 604 588 254 120 551 421 476 298 900 710 915 343 445 421 986 867 445 588 219 356 919 105 584 875 991 604 776 919 588 254 919 421 356 348 105 551 15 113 919 15 356 523 343 155 770 9...