QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#249031#7514. Clique ChallengeuroskWA 0ms3664kbC++113.4kb2023-11-11 23:55:072023-11-11 23:55:08

Judging History

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

  • [2023-11-11 23:55:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2023-11-11 23:55:07]
  • 提交

answer

#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define eb emplace_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define si(a) (ll)(a.size())
using namespace std;

#define mod 1000000007
#define maxn 1005
ll add(ll x,ll y){
    x+=y;
    if(x<0){
        x%=mod;
        x+=mod;
    }else{
        if(x>=mod) x%=mod;
    }
    return x;
}
ll mul(ll a,ll b){
	ll ans = (a*b)%mod;
	if(ans<0) ans+=mod;
	return ans;
}
ll n,m;
vector<ll> g[maxn];
ll b[maxn];
ll deg[maxn];
bool cmp(ll x,ll y){
    return deg[x]<deg[y];
}
bitset<maxn> gr[maxn];
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n >> m;
    for(ll i = 1;i<=n;i++) gr[i][i] = 1;
    for(ll i = 1;i<=m;i++){
        ll x,y; cin >> x >> y;
        g[x].pb(y);
        gr[x][y] = gr[y][x] = 1;
        g[y].pb(x);
        deg[x]++; deg[y]++;
    }
    ll ans = 0;
    iota(b+1,b+1+n,1);
    for(ll i = 1;i<=n;i++){
        sort(b+1,b+1+n,cmp);
        ll u = b[i];
        vector<ll> v;
        for(ll s : g[u]){
            if(gr[u][s]) v.pb(s);
        }
        ll c = si(v);
        if(c==0) continue;
        ll cl = c/2,cr = c-cl;
        c++;
        vector<ll> mask((1LL<<c));
        vector<bool> okl((1LL<<c));
        vector<bool> okr((1LL<<c));
        vector<ll> curl((1LL<<c));
        vector<ll> curr((1LL<<c));
        vector<ll> dp((1LL<<c));
        c--;
        //vector<ll> mask((1<<cl));
        for(ll i = 0;i<c;i++){
            for(ll j = 0;j<c;j++){
                if(gr[v[i]][v[j]]) mask[i]|=(1<<j);
            }
        }
        for(ll i = 0;i<(1LL<<cl);i++){
             curl[i] = (1LL<<c)-1;
            for(ll j = 0;j<cl;j++) if((1<<j)&i) curl[i]&=mask[j];
            okl[i] = 1;
            for(ll j = 0;j<cl;j++){
                if((1LL<<j)&i){
                    if(!((1LL<<j)&curl[i])) okl[i] = 0;
                }
            }
        }
        //cer(v);

        for(ll i = 0;i<(1LL<<cr);i++){
             curr[i] = (1LL<<c)-1;
            for(ll j = cl;j<c;j++) if((1<<(j-cl))&i) curr[i]&=mask[j];
            okr[i] = 1;
            for(ll j = cl;j<c;j++){
                if((1LL<<(j-cl))&i){
                    if(!((1LL<<(j))&curr[i])) okr[i] = 0;
                }
            }
            dp[i] = okr[i];
        }

        for(ll j = 0;j<cr;j++){
            for(ll i = 0;i<(1LL<<cr);i++){
                if((1LL<<j)&i) dp[i]=add(dp[i],dp[i^(1LL<<j)]);
            }
        }
        for(ll i = 0;i<(1LL<<cl);i++){
            ll k = 0;
            for(ll j = cl;j<c;j++) if((1LL<<j)&curl[i]) k|=(1LL<<(j-cl));
            if(okl[i]) ans = add(ans,dp[k]);
        }
        for(ll s : g[u]){
            if(!gr[s][u]) continue;
            deg[s]--;
            deg[u]--;
            gr[u][s] = gr[s][u] = 0;
        }
    }
    cout<<ans<<endl;
	return (0-0);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3664kb

input:

3 2
1 2
2 3

output:

4

result:

wrong answer 1st lines differ - expected: '5', found: '4'