QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#240044 | #7514. Clique Challenge | Crying | WA | 0ms | 13944kb | C++17 | 1.8kb | 2023-11-05 09:42:45 | 2023-11-05 09:42:46 |
Judging History
This is the latest submission verdict.
- [2025-01-18 20:43:34]
- hack成功,自动添加数据
- (/hack/1457)
- [2023-11-05 09:42:45]
- Submitted
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)cout<<arr[i]<<" ";cout<<endl;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 13944kb
input:
3 2 1 2 2 3
output:
1 3 2 5
result:
wrong answer 1st lines differ - expected: '5', found: '1 3 2 '