HDU6321:Problem C. Dynamic Graph Matching(状压dp)

Graph Matching随想 图网络和图配对Graph Neural NetworkGraph Matching Graph Neural Network 首先简要复习图网络GNN部分。 对比一下图网络和一般网络异同。 X→WX \bm{X} \rightarrow \bm{WX} X→WX 这是一般的神经网络。而对于图网络来说 (A,X)→W(A,X) (\bm{A},\bm{X}) \rightarrow \bm{W}(\bm{A},\bm{X}) (A,X)→W(A,X) 相比于一般网络而言,其输入部分可以认为是多了一部分图的信 阅读详情

Problem Description

In the mathematical discipline of graph theory, a matching in a graph is a set of edges without common vertices.
You are given an undirected graph with n vertices, labeled by 1,2,...,n. Initially the graph has no edges.
There are 2 kinds of operations :
+ u v, add an edge (u,v) into the graph, multiple edges between same pair of vertices are allowed.
- u v, remove an edge (u,v), it is guaranteed that there are at least one such edge in the graph.
Your task is to compute the number of matchings with exactly k edges after each operation for k=1,2,3,...,n2. Note that multiple edges between same pair of vertices are considered different.

 

 

Input

The first line of the input contains an integer T(1≤T≤10), denoting the number of test cases.
In each test case, there are 2 integers n,m(2≤n≤10,nmod2=0,1≤m≤30000), denoting the number of vertices and operations.
For the next m lines, each line describes an operation, and it is guaranteed that 1≤u<v≤n.

 

 

Output

For each operation, print a single line containing n2 integers, denoting the answer for k=1,2,3,...,n2. Since the answer may be very large, please print the answer modulo 109+7.

 

 

Sample Input

 

1 4 8 + 1 2 + 3 4 + 1 3 + 2 4 - 1 2 - 3 4 + 1 2 + 3 4

 

 

Sample Output

 

1 0 2 1 3 1 4 2 3 1 2 1 3 1 4 2

 

 

Source

2018 Multi-University Training Contest 3

题意:给一个图有N个点和若干个询问,每个询问增或者删一条边,每个询问输出选择1~N/2条不相交的边的方案数。

思路:因为点的个数很少,所以dp[i]表示i状态点集的选边方案数,因为X个点限定选X/2条边,所以很方便转移。

/*dp[i][j]表示j状态点集的方案数*/

# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
int dp[2][1025], num[1025], sta[1025], ans[6];
void add(int &x, int y)
{
    x += y;
    if(x >= mod) x -= mod;
}
void sub(int &x, int y)
{
    x -= y;
    if(x < 0) x += mod;
}
int main()
{
    char c;
    int n, q, T, u, v, cnt=0;
    for(int i=0; i<1024; ++i)
    {
        num[i]= num[i>>1]+(i&1);//i的二进制有几个1
        if(~num[i]&1) sta[cnt++] = i;//sta保存偶数个1的二进制数
    }
    for(scanf("%d",&T);T;--T)
    {
        memset(dp, 0, sizeof(dp));
        scanf("%d%d",&n,&q);
        int now = 0;
        dp[0][0] = 1;
        while(q--)
        {
            getchar();
            c = getchar();
            scanf("%d%d",&u,&v);
            --u,--v;
            memset(ans, 0, sizeof(ans));
            int tmp = (1<<u) | (1<<v);
            if(c == '+')
            {
                for(int i=0; i<cnt&&sta[i]<(1<<n); ++i)
                {
                    int cur = sta[i];
                    dp[now^1][cur] = dp[now][cur];
                    if((cur&tmp) == tmp) add(dp[now^1][cur],dp[now][cur^tmp]);
                    add(ans[num[cur]/2],dp[now^1][cur]);
                }
            }
            else
            {

                for(int i=0; i<cnt&&sta[i]<(1<<n); ++i)
                {
                    int cur = sta[i];
                    dp[now^1][cur] = dp[now][cur];
                    if((cur&tmp) == tmp) sub(dp[now^1][cur],dp[now][cur^tmp]);
                    add(ans[num[cur]/2],dp[now^1][cur]);
                }
            }
            now ^= 1;
            for(int i=1; i<=n/2; ++i) printf("%d%c",ans[i],i==n/2?'\n':' ');
        }
    }
    return 0;
}

 

ComfyUI+minimaxh3本地部署:漫剧分镜批量生成工作流全实操 视频生成模型正从云端API向本地化部署迁移,背后的技术逻辑是将扩散模型的文本编码、潜空间采样、VAE解码等阶段拆分为可编排的独立环节。ComfyUI作为节点化管线工具,恰好能以可视化连线方式管理这些阶段,让生成过程可控、可复用、可批量执行。minimaxh3模型支持本地推理,配合LoRA微调与参数优化,能够在保证角色一致性的前提下,从分镜脚本批量产出连续剧情片段,规避云端排队、成本高、素材不可控等工程问题。这套工作流广泛应用于漫剧、短剧和动态条漫的工业化生产,尤其适合需要高频迭代分镜草稿的内容团队。文本以零 阅读详情

相关推荐

19-5 ACC 自适应巡航控制系统需求

本专题由深圳季连AIgraphX李博及团队出品,主要讲解ACC自适应巡航控制系统的开发与仿真测试。具体说来,包括ACC标准/法规分析、系统需求、系统架构、软件需求、软件架构、算法建模、验证场景分析、仿真实验搭建等内容。 本节主要讲ACC系统需求。

AIgraphX 1100

Graph Matching

受严骏驰老师讲座内容启发,最近项目中一个关键问题才找到了一些解决途径,为了能够快速对Graph Matching的起源和发展现状有一定了解,从而形成知识体系来更好得解决问题,准备慢下来,把这些知识沉淀下来,写成一篇blog。 (讲座链接:https://www.bilibili.com/video/BV1Zf4y1S7Zr) Graph Matching 属于一种组合优化问题,图这类数据结构形式在推荐系统、知识图谱等中最为常见,而在计算机视觉领域中,为解决少样本学习或目标检测类别长尾分布等,图结构也有较多工

AIWCZ的博客 2057

Anaconda 2026.07 安装配置完全指南:从下载到PyCharm整合

Python 环境管理一直是开发者绕不开的课题,而 Anaconda 作为集成了 conda 与 300+ 科学计算包的发行版,极大降低了环境配置门槛。其核心价值在于通过虚拟环境实现不同项目的依赖隔离,避免版本冲突。但在实际安装与配置过程中,用户常因版本差异、镜像源访问慢、与 IDE 集成不畅等问题陷入困境。本文以 Anaconda 2026.07 为例,系统讲解从官方渠道或国内镜像源下载、安全校验、安装选项分析、conda 命令初始化,到配置清华镜像源、创建指定 Python 版本的虚拟环境,再到与 Py

weixin_32520095的博客 453

图匹配(Graph Matching)入门学习笔记——以《Factorized Graph Matching》为例(一)

这篇文章本身是图匹配经典论文《Factorized Graph Matching》的阅读笔记,后来发现该文介绍并串联了许多图匹配相关的知识,甚至可以看作一个小小的综述性文章,因此就作为图匹配的学习笔记了。因为笔者本人才疏学浅,对于图匹配也是刚刚开始接触,所以文章内容难免存在纰漏和错误,也欢迎各位朋友批评指正。

深视 1万+

别再死磕NFP了!用Python+遗传算法搞定异形件自动排版(附完整代码)

本文介绍了如何利用Python和遗传算法实现异形件智能排版,解决传统NFP方法计算复杂的问题。通过Shapely库处理几何运算和DEAP库搭建遗传算法框架,结合模拟退火策略避免局部最优,显著提升材料利用率。附完整代码和优化技巧,适用于服装裁剪、金属加工等行业。

weixin_26965807的博客 241

【HDR】曝光融合(Exposure Fusion)

在曝光融合(Exposure Fusion)算法问世之前,多曝光序列合成用于显示的HDR需要两个步骤,第一步是将多张不同曝光的低动态范围图像合成为HDR(例如Debevec提出的加权融合方法),通常HDR为12bit或者16bit;第二步是通过tonemapping对高动态范围HDR进行压缩以支持低动态范围显示设备(例如Durand提出的基于双边滤波的tonemapping算法),一般会压缩至8bit。

专注人工智能,主攻CV 1万+

图匹配(Graph Matching)

给定两个图和并定义两个关联矩阵(Affinity Matrix):表示两幅图节点和节点之间的相似度:表示两幅图边和边之间的相似度:表示图中的第个节点和图的第个节点之间的相似程度:表示图中的第个边和图的第个边之间的相似程度图匹配问题就变成寻找两幅图之间最优的匹配关系,使得节点间的相似度和边之间的相似度之和最大。式(1)中第一项表示匹配节点之间的相似度之和式(1)中第二项表示匹配边之间的相似度之和其中表示了两幅图节点之间的匹配关系,表示图中的第个节点和图的第。

m0_61595251的博客 2965

Cursor Pro版保姆级开通教程:绕过7天试用,支付宝一步搞定(附地区报错解决方案)

本文详细介绍了Cursor Pro版的订阅流程,包括支付宝支付步骤和解决区域报错的实用方案。针对开发者常见的网络问题和云服务器配置需求,提供了从本地环境调整到云端部署的完整指南,帮助用户高效解锁Pro版的代码补全、私有代码库等核心功能。

weixin_28710999的博客 2150

LBD算法 - Graph matching 图匹配算法分析

上一步我们进行了线特征的提取和描述,接下来我们进行线特征的匹配。在此之前我们先通过预处理将一些明显无法匹配的特征给消除,以降低图匹配问题的维度。

Xuefeng_BUPT的博客 1万+

Winform使用TreeView控件实现带复选框的三态树

刚接触c#,项目中用到Treeview实现三态,即选中、未选中、半选中状态,并且要求父子节点选择联动,效果类似下图网上有很多例子,于是研究了一下,结合网上大佬们的例子,所以在这里记录一下。首先新建一个Winform工程拖个TreeView控件,然后运行。。。嗯。。。加点数据吧。private void CreateTree() { TreeNode anime = new TreeNode...

laoyezha的博客 2万+

LeGo-LOAM源码篇:源码分析(3)

mapOptmization.cpp,主要内容包括回环检测、scan-to-map位姿优化、因子图。

slamml 1388

HDU6321 Problem C. Dynamic Graph Matching 状压DP

HDU6321 Problem C. Dynamic Graph Matching 对于每个 检查其是否可以转移到 (对应二进制位上相加)       表示 对应二进制1位的个数   统计个点的匹配数 ,表示集合中有条边的种类数 #include &lt;bits/stdc++.h&gt; using namespace std; const int MAX=1&lt;&lt...

Qianyri的博客 296

华为od统一考试B卷【食堂供餐】Python 实现

某公司员工食堂以盒饭方式供餐。为将员工取餐排队时间降低为0,食堂的供餐速度必须要足够快。现在需要根据以往员工取餐的统计信息,计算出一个刚好能达成排队时间为0的最低供餐速度。即,食堂在每个单位时间内必须至少做出多少份盒饭才能满足要求。

MISAYAONE的博客 8788

HDU - 6321 Problem C. Dynamic Graph Matching (状压dp)

题意:给定一个N个点的零图,M次操作,添加或删除一条边,每一次操作以后,打印用1,2,...N/2条边构成的匹配数。 分析:因为N的范围很小,所以可以把点的枚举状态用二进制表示集合。用一维数组dp[S]表示二进制集合为S的点集的匹配数。 每次加边操作,从大到小遍历集合,dp[S]+=dp[S-u-v];删边操作,从小到大遍历集合,dp[S]-=dp[S-u-v]。 预处理出每个1024之内每...

weixin_30693183的博客 172

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

HDU 6321 Problem C. Dynamic Graph Matching(状压dp)

题目链接 Problem C. Dynamic Graph Matching Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 984    Accepted Submission(s): 393 Problem Descript...

咸鱼有梦想 293

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

HDU 6321 Problem C. Dynamic Graph Matching(状压DP)

Description 有nnn个点,mmm次加边或删边操作,每次操作结束后查询kkk匹配的方案数,k=1,2,...,n2k=1,2,...,n2k=1,2,...,\frac{n}{2} Input 第一行输入一整数TTT表示用例组数,每组用例首先输入两个整数n,mn,mn,m,之后mmm行每行表示一种操作 (1≤T≤10,1≤n≤10,n%2=0,1≤m≤30000)(1≤T≤10,...

ZSQ 291

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

HDU 6321 Problem C. Dynamic Graph Matching (状压dp)

题意:给定一个N个点的零图,M次操作,添加或删除一条边,每一次操作以后,打印用1,2,…N/2条边构成的匹配数。 分析:因为N的范围很小,所以可以把点的枚举状态用二进制表示集合。用一维数组dp[S]表示二进制集合为S的点集的匹配数。 每次加边操作,从大到小遍历集合,dp[S]+=dp[S-u-v];删边操作,从小到大遍历集合,dp[S]-=dp[S-u-v]。 预处理出每个1024之内每个数...

城南的花 225

2018HDU多校3-Problem C. Dynamic Graph Matching(hdu 6321)-状压dp

题意: 有n个点,m个操作,操作为增加一条边或删除一条边,每次操作后输出1~n/2个边的匹配个数,k边匹配的定义为:取k条边为一组,这一组边中没有公共点,求能找出多少组 思路: 因为n的范围2~10,数据很小,考虑状压dp,设计dp方程,dp[now][S]表示now状态下,点集为S时,已经匹配的方案数。 对于加边操作,dp[i][S]=dp[i-1][S]+dp...

Ogmx的博客 260

杭电多校第三场HDU6321 Problem C. Dynamic Graph Matching (状压DP)

  Problem C. Dynamic Graph Matching Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 1238    Accepted Submission(s): 516   Problem Descript...

DlPF_C的博客 322

hdu 6321 Problem C. Dynamic Graph Matching【2018 Multi-University Training Contest 3 】【状压DP】

【题意】: t组样例,n个点(保证是偶数),m次操作,每次操作告诉你两个点,给这两个点加一条边或者减一条边,减边的话保证减边之前至少有一条边。 每次操作之后输出 整个图中 匹配大小为 j 的数量   。两条重边被认为是不一样的。 【题解】: n &lt;= 10,每个点有被占用和不被占用两种状态,所以一共有2^10种状态。 如果这次增加了 a b这两个点的一条边,那么就从 0 - 102...

顾业鸣 230

HDU 6321 Problem C. Dynamic Graph Matching (2018多校3) 状压DP

Problem C. Dynamic Graph Matching Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 1341    Accepted Submission(s): 561 Problem Description ...

LinzhiQQQ的博客 337

2018 Multi-University Training Contest 3 1003 / hdu6321 Problem C. Dynamic Graph Matching 状压dp...

Problem C. Dynamic Graph Matching 题意: 给定一个n个点的无向图,m次加边或者删边操作。在每次操作后统计有多少个匹配包含k= 1,2,...,n2条边。 2≤n≤10,1≤m≤30000。 Shortest judge solution: 770 bytes 题解: 设f[i][S]表示前i次操作之后,S集合的点已经匹配的方案数。 对于加边操作,显然f[i][S]...

weixin_30933531的博客 150

C - Dynamic Graph Matching HDU - 6321

状压dp,先记录偶数状态,然后直接暴力转移即可。 #include<iostream> #include<cstring> #include<algorithm> #include<cmath> #include<cstdlib> #include<climits> #include<stack> #include...

weixin_44019404的博客 156

HDU 6321Problem C. Dynamic Graph Matching(模拟,状压)

题目:给你n个点,m个操作,每种操作要么加一条边要么减一条边,紧接着询问当前选出1条无公共端点的边,2条无公共端点的边,3条.....n/2条无公共端点边时分别有多少种不同的选择。(n&lt;=10)  思路:真是刺激,比赛时想到了状压没想到怎么搞,然后疯狂算暴力的复杂度。感觉还可以,应该不会T。交了一发,疯狂刷新后结果TLE。然后发现还可以优化下常数,直接把下面的代码写到init里面预处理出4...

XFire的博客 330

HDU 6321 2018HDU多校赛 第三场 Dynamic Graph Matching(状态压缩dp)

大致题意:一开始图是空的,总共有m个操作,每次可以添加或者删除一条边,每个操作结束后,输出这个图里面匹配数为1,2,...,n/2的方案数。看到n的范围是10,然后操作数是3W,就应该直接想到这是一个状压dp的……一开始还往组合数学,容斥原理方面去想……还好最后做出来了。首先,我们考虑加入一条边之后会产生多少贡献。显然是加入这条边之前,所有不包含这条边以及这两个点的匹配的数目。我们用dp[status][i]表示取的点的状态为status,然后构成i个匹配方案数。当加入边(x,y)之后,dp[status|

alpc_qleonardo 459

HDU 6321 Problem C. Dynamic Graph Matching

Link:http://acm.hdu.edu.cn/showproblem.php?pid=6321 这道题是激发我学状压的题,很感激,即使现在还一知半解,DP还是比较玄幻的 题意: 一开始给你n个独立节点,m次操作,操作分两类, 1 加边 2 删除边。 问你每次操作后,选择k = 1、2、3、4……n/2 条边,这k条边没有公共节点。 我对这道题的理解: 状态state表示当前...

林鸿清的blog 229
上一篇: HDU6319:Problem A. Ascending Rating(单调队列)
下一篇: HDU6356:Glad You Came(区间最值 + 倍增)
junior19
码龄10年 118粉丝 615原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值