QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#455317#7514. Clique ChallengeKevin5307WA 1ms9844kbC++232.1kb2024-06-26 09:09:272024-06-26 09:09:28

Judging History

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

  • [2024-06-26 09:09:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9844kb
  • [2024-06-26 09:09:27]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
vector<int> G[1010];
int deg[1010];
bool E[1010][1010];
ll msk[1010];
int ok1[1<<23],ok2[1<<23],con[1<<23];
ll calc(vector<int> vec)
{
	int s=sz(vec);
	int h1=s/2,h2=(s+1)/2;
	assert(h1<=23&&h2<=23);
	memset(msk,0,sizeof(ll)*(s+5));
	for(int i=0;i<s;i++)
		for(int j=0;j<s;j++)
			if(E[vec[i]][vec[j]])
				msk[i]|=(1ll<<j);
	for(int i=0;i<1<<h1;i++)
		if(!i)
			ok1[i]=1;
		else
		{
			int p=(i&(-i));
			int po=__builtin_ctz(p);
			if((msk[po]&i)!=(i^p))
				ok1[i]=0;
			else
				ok1[i]=ok1[i^p];
		}
	for(int i=0;i<1<<h2;i++)
		if(!i)
			ok2[i]=1;
		else
		{
			int p=(i&(-i));
			int po=__builtin_ctz(p);
			if(((msk[po+h1]>>h1)&i)!=(i^p))
				ok2[i]=0;
			else
				ok2[i]=ok2[i^p];
		}
	for(int j=0;j<h2;j++)
		for(int i=0;i<1<<h2;i++)
			if(i>>j&1)
				ok2[i]+=ok2[i^(1<<j)];
	ll ret=0;
	con[0]=(1<<h2)-1;
	for(int i=0;i<1<<h1;i++)
	{
		if(i)
		{
			int p=(i&(-i));
			int po=__builtin_ctz(p);
			con[i]=con[i^p]&(msk[po]>>h1);
		}
		ret+=ok2[con[i]];
	}
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
		deg[u]++;
		deg[v]++;
		E[u][v]=E[v][u]=1;
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		vector<int> vec;
		for(auto j:G[i])
			if(mp(deg[j],j)>mp(deg[i],i))
				vec.pb(j);
		ans+=calc(vec);
	}
	cout<<ans%1000000007<<endl;
	return 0;
}

詳細信息

Test #1:

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

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

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

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

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:

1437

result:

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