惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
MyScale Blog
MyScale Blog
博客园 - Franky
The Cloudflare Blog
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
The Blog of Author Tim Ferriss
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
Martin Fowler
Martin Fowler
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
腾讯CDC
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
云风的 BLOG
云风的 BLOG

某岛

AtCoder Beginner Contest 409 Luogu P5325. 【模板】Min_25 筛 UOJ #188. 【UR #13】Sanrd AtCoder Beginner Contest 371 AtCoder Beginner Contest 369 RPGMaker 2k3 百科 OneShot 的考古 2024“开创拓芯”游戏创享节的相关记录 CJ 回来后的戒断反应 Luogu P5308 [COCI2018-2019#4] Akvizna wqs 二分 歌唱王国 Lean 相关 BZOJ 3153. Sone1 The 2023 ICPC World Finals Luxor 新巴别塔 Sora 的想象与思考 Facebook Hacker Cup 2023 Round 1 AtCoder Beginner Contest 322 LLaMA 2 相关 HuggingFace AI Game Jam ACL 2023 Trans 相关… Luogu P2053. [SCOI2007] 修车 Luogu P1973. [NOI2011] NOI 嘉年华 Luogu P1933. [NOI2010] 旅行路线 Luogu P1954. [NOI2010] 航空管制 Luogu P2048. [NOI2010] 超级钢琴 Luogu P2046. [NOI2010] 海拔 Luogu P3227. [HNOI2013] 切糕
Luogu P10221. [省选联考 2024] 重塑时光
2024-07-09 · via 某岛

首先会做这个题。 https://www.luogu.com.cn/problem/P6846

const int N = 18;

struct Edge {
    int a, b;
    void in() {
        RD(a, b); --a; --b;
        a = _1(a); b = _1(b);
    }
    bool in(int s) {
        return (s&a)&&(s&b);
    }
} E[N*N/2];

Int f[1<<N]; bool bad[1<<N];
int n, m;

int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    RD(n, m); REP(i, m) E[i].in();

<pre><code>FOR(s, 1, _1(n)) {
    REP(i, m) if (E[i].in(s)) {
        bad[s] = 1;
        break;
    }
}

f[0] = 1; FOR(s, 1, _1(n)) {
    REP_SS(ss, s) if (!bad[ss]) {
        if (count_bits(ss)&amp;amp;1) f[s] += f[s^ss];
        else f[s] -= f[s^ss];
    }
}
cout &amp;lt;&amp;lt; f[_U(n)] * m / 2 &amp;lt;&amp;lt; endl;
</code></pre>

}

然后发现这个题只要加个维。。。

const int N = 15;

Int f[N+2][1&lt;&lt;N], g[N+2][1&lt;&lt;N], fact[N+2];
bool bad[1&lt;&lt;N]; int adj[1&lt;&lt;N];
int n, m, k;

struct Edge {
    int a, b;
    void in() {
        RD(a, b); --a; --b;
        a = _1(a); b = _1(b);
        adj[a] |= b;
    }
    bool in(int s) {
        return (s&amp;a)&amp;&amp;(s&amp;b);
    }
} E[N*(N-1)/2];

int main() {

#ifndef ONLINE_JUDGE
    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);
    //freopen(&quot;out.txt&quot;, &quot;w&quot;, stdout);
#endif
    RD(n, m, k); ++k; REP(i, m) E[i].in();
    fact[0] = 1; REP_1(i, k) fact[i] = fact[i-1] * i;

<pre><code>FOR(s, 1, _1(n)) {
    adj[s] |= adj[s^low_bit(s)];
    REP(i, m) if (E[i].in(s)) {
        bad[s] = 1;
        break;
    }
}

g[0][0] = 1; REP_1(i, k) FOR(s, 1, _1(n)) {
    REP_SS(ss, s) if (!bad[ss]) {
        if (count_bits(ss)&amp;amp;1) g[i][s] += g[i-1][s^ss];
        else g[i][s] -= g[i-1][s^ss];
    }
}

f[0][0] = 1; REP_1(i, k) FOR(s, 1, _1(n)) {
    REP_1(ii, i) REP_SS(ss, s) if (!(adj[ss^s]&amp;amp;ss)) {
        Int d = g[ii][ss] * f[i-ii][s^ss];
        if (ii&amp;amp;1) f[i][s] += d;
        else f[i][s] -= d;
    }
}
Int z = 0; REP_1(i, k) z += fact[k] / fact[k-i] * f[i][_U(n)];
cout &amp;lt;&amp;lt; z &amp;lt;&amp;lt; endl;
</code></pre>

}

Posted by xiaodao
Category: 日常