QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#198414#7514. Clique Challengevme50WA 1ms10168kbC++141.6kb2023-10-03 13:44:432023-10-03 13:44:43

Judging History

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

  • [2023-10-03 13:44:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:10168kb
  • [2023-10-03 13:44:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 1005
#define M (1<<24)+5
#define MOD 1000000007
#define ctz __builtin_ctz
#define ll long long
#define pb push_back
int n,m,U[N],V[N],dg[N],o[N],id[N],stt1[N],stt2[N],stt3[N];
int z1[M],z2[M],z3[M];ll ans;bool e1[N][N];vector<int> e[N];
ll slv(int n)
{
	int n1=max((n-3)/2,0),n2=n-n1;ll res=0;
	z1[0]=z2[0]=1;z3[0]=(1<<n1)-1;for(int i=1;i<=n;++i) e1[i][i]=1;
	fill(stt1+1,stt1+n1+1,0);fill(stt2+1,stt2+n2+1,0);fill(stt3+1,stt3+n2+1,0);
	for(int i=1;i<=n1;++i) for(int j=1;j<=n1;++j) if(e1[i][j]) stt1[i]|=1<<j-1;
	for(int i=1;i<=n2;++i) for(int j=1;j<=n2;++j) if(e1[n1+i][n1+j]) stt2[i]|=1<<j-1;
	for(int i=1;i<=n2;++i) for(int j=1;j<=n1;++j) if(e1[n1+i][j]) stt3[i]|=1<<j-1;
	for(int i=1,t;i<1<<n1;++i)
		t=ctz(i),z1[i]=z1[i^(1<<t)] && (!((stt1[t+1]^(1<<n1)-1)&i));
	for(int i=1,t;i<1<<n2;++i)
	{
		t=ctz(i);z2[i]=z2[i^(1<<t)] && (!((stt2[t+1]^(1<<n2)-1)&i));
		z3[i]=z3[i^(1<<t)]&stt3[t+1];
	}
	for(int i=1;i<1<<n1;i*=2) for(int j=0;j<1<<n1;j+=i*2)
		for(int k=0;k<i;++k) z1[i+j+k]+=z1[j+k];
	for(int i=0;i<1<<n2;++i) res+=1ll*z2[i]*z1[stt3[i]];return res;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;++i) scanf("%d %d",&U[i],&V[i]),++dg[U[i]],++dg[V[i]];
	for(int i=1,u,v;i<=m;++i)
	{u=U[i];v=V[i];if(dg[u]>dg[v] || (dg[u]==dg[v] && u>v)) swap(u,v);e[u].pb(v);}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=o[0];++j) fill(e1[j]+1,e1[j]+o[0]+1,0);
		o[0]=0;for(auto j:e[i]) o[id[j]=++o[0]]=j;
		for(auto j:e[i]) for(auto k:e[j]) if(id[k])
			e1[id[j]][id[k]]=e1[id[k]][id[j]]=1;
		ans+=slv(o[0]);for(auto j:e[i]) id[j]=0;
	}printf("%lld\n",ans%MOD);return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

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

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: 10168kb

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:

1304

result:

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