QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#564272#7514. Clique Challengeliujunyi123TL 0ms44612kbC++141.3kb2024-09-14 21:44:102024-09-14 21:44:11

Judging History

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

  • [2024-09-14 21:44:11]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:44612kb
  • [2024-09-14 21:44:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1005,M=(1<<23),mod=1e9+7;
int n,m,tot,ans,lg[M],d[N],E[N],E1[N],s1[M],s2[M],f[M],id[N],g[N][N];
vector<int> e[N],ve,v1,v2;
void qm(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int main(){
	scanf("%d%d",&n,&m),lg[0]=-1;
	for(int i=1;i<M;i++)lg[i]=lg[i>>1]+1;
	for(int i=1,x,y;i<=m;i++)scanf("%d%d",&x,&y),g[x][y]=g[y][x]=1,d[x]++,d[y]++;
	for(int i=1;i<=n;i++){v1.clear(),v2.clear(),ve.clear();
		for(int j=1;j<=n;j++)if(g[i][j]&&(d[j]>d[i]||(d[j]==d[i]&&j>i)))ve.push_back(j);
		for(auto j:ve){
			if(v1.size()<(ve.size()+1)/2)v1.push_back(j);
			else v2.push_back(j);
		}
		for(int j=0;j<v1.size();j++)id[v1[j]]=j,E[j]=0;
		for(int j=0;j<v2.size();j++)id[v2[j]]=j;
		for(auto u:v1)for(auto v:v1)if(!g[u][v]&&u!=v)E[id[u]]|=(1<<id[v]),E[id[v]]|=(1<<id[u]);
		for(auto u:v1)for(auto v:v2)if(!g[u][v])E1[id[u]]|=(1<<id[v]);
		int tmp=(1<<v1.size())-1,tp2=(1<<v2.size())-1;
		for(int s=0;s<=tmp;s++){
			s1[s]=s2[s]=0;
			if(s){
				s1[s]=s1[s^(s&-s)]|E[lg[(s&-s)]];
				s2[s]=s2[s^(s&-s)]|E1[lg[(s&-s)]];
			}
			if(!(s1[s]&s))f[tp2^E1[s]]++;
		}
		for(int j=0;j<v2.size();i++)
			for(int s=0;s<=tp2;s++)if(!((s>>j)&1))f[s]+=f[s^(1<<j)];
		for(int s=0;s<=tp2;s++)qm(ans,f[s]),f[s]=0;
	}
	printf("%d\n",ans);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 44612kb

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: -100
Time Limit Exceeded

input:

3 3
1 2
1 3
2 3

output:


result: