QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#240045#7514. Clique ChallengeCryingWA 3ms22148kbC++171.8kb2023-11-05 09:43:122023-11-05 09:43:13

Judging History

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

  • [2023-11-05 09:43:13]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:22148kb
  • [2023-11-05 09:43:12]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define op(x) ((x&1)?x+1:x-1)
#define odd(x) (x&1)
#define even(x) (!odd(x))
#define lc(x) (x<<1)
#define rc(x) (lc(x)|1)
#define lowbit(x) (x&-x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
using namespace std;
const int MAXN = 1010,MAXM = 50,mod = 1e9+7;
void add(ll& x,ll y){x = (x+y)%mod;}

int n,m,G[MAXN][MAXN],deg[MAXN],arr[MAXN];
int p[MAXM],tot,L[MAXM],R[MAXM],lb[1<<22];
ll ans;

bool tL[1<<22],tR[1<<22];
int fL[1<<22];
ll dp[1<<22];

ll calc(){
	if(tot==0)return 1;
	else if(tot==1)return 2;
	int mid = tot/2; //[0,mid) & [mid,tot)
	rep(i,0,tot-1){
		int u = p[i];
		L[i]=R[i]=0; 
		rep(j,0,tot-1){
			int v = p[j];
			if(G[u][v])(j<mid)?(L[i]|=(1<<j)):(R[i]|=(1<<(j-mid)));
		}
	}
	int x = mid,y = tot-mid;
	tL[0] = tR[0] = 1;
	fL[0] = (1<<y)-1;
	rep(S,1,(1<<x)-1){
		int u = lb[lowbit(S)],to = S^(1<<u);
		tL[S] = tL[to] & ((L[u]&to)==to);
		fL[S] = fL[to] & R[u];
	}

	rep(i,0,(1<<y)-1)dp[i] = 0;
	rep(i,0,(1<<x)-1)if(tL[i])dp[fL[i]]++;
	rep(i,0,y-1)per(S,(1<<y)-1,0)if(S>>i&1)add(dp[S^(1<<i)],dp[S]);

	ll sum = 0;

	rep(S,1,(1<<y)-1){
		int u = lb[lowbit(S)],to = S^(1<<u);
		tR[S] = tR[to] & ((R[u-mid]&to)==to);
	}
	rep(S,0,(1<<y)-1)if(tR[S])add(sum,dp[S]);
	return sum;
}

int main(){
	rep(i,0,21)lb[1<<i] = i;

	cin>>n>>m;
	rep(i,1,m){
		int u,v;cin>>u>>v;
		G[u][v]=G[v][u]=1;deg[u]++;deg[v]++;
	}
	iota(arr+1,arr+1+n,1); sort(arr+1,arr+1+n,[&](int x,int y){return deg[x]<deg[y];});
	rep(i,1,n){
		int u = arr[i]; 
		tot = 0;
		rep(j,i+1,n){
			int v = arr[j];
			if(G[u][v])p[tot++] = v;
		}
		add(ans,calc());
	}
	cout<<ans<<endl;

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 13852kb

input:

3 2
1 2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 20060kb

input:

3 3
1 2
1 3
2 3

output:

7

result:

ok single line: '7'

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 22148kb

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:

1240

result:

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