[最长路][二分图]Codeforces 542 E. Playing on Graph

图论的证明套路和图论之美 图论之最 图论常用奇技淫巧 最短/最长路: 不含奇圈⇒\Rightarrow⇒二部图:取最短的路。还有一个技巧:两条路必有分离的点,取最后一个分离的点 极大极小取法 Euler图的证明 ​ S={G∣G连通且无奇度顶点,G不是Euler图}S=\{G|G连通且无奇度顶点,G不是\text{Euler图}\}S={G∣G连通且无奇度顶点,G不是Euler图} 取出边... 阅读详情

Solution

如果图中存在奇环,那么这个奇环缩了以后还是会产生一个奇环,最后一定会缩到一个三元环,显然无解。
所以说合法的图一定是一个二分图。
对于从某一点开始的链,把距离它距离相同的点可以缩起来,因为这些点肯定在二分图的某一部,是没有边相邻的。所以答案就是每个联通块的直径长度的和。
跑最长路就好了

#include <bits/stdc++.h>
using namespace std;

const int N = 1010;
const int M = 101010;

inline char get(void) {
    static char buf[100000], *S = buf, *T = buf;
    if (S == T) {
        T = (S = buf) + fread(buf, 1, 100000, stdin);
        if (S == T) return EOF;
    }
    return *S++;
}
template<typename T>
inline void read(T &x) {
    static char c; x = 0; int sgn = 0;
    for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
    for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
    if (sgn) x = -x;
}

int n, m, Gcnt, clc, ans, x, y, cnt;
struct edge {
    int to, next;
    edge(int t = 0, int n = 0):to(t), next(n) {}
};
edge G[M << 1];
int head[N], vis[N], pre[N], dep[N], col[N], dis[N];
queue<int> Q;

inline void AddEdge(int from, int to) {
    G[++Gcnt] = edge(to, head[from]); head[from] = Gcnt;
    G[++Gcnt] = edge(from, head[to]); head[to] = Gcnt;
}
inline void dfs(int u, int d) {
    col[u] = cnt; pre[u] = ++clc; dep[u] = d;
    for (int i = head[u]; i; i = G[i].next) {
        if (!pre[G[i].to]) dfs(G[i].to, d ^ 1);
        else if (pre[G[i].to] < pre[u] && (dep[u] ^ dep[G[i].to] ^ 1)) ans = -1;
    }
}
inline int dia(int u) {
    Q.push(u); vis[u] = ++clc; pre[u] = 0;
    while (!Q.empty()) {
        u = Q.front(); Q.pop();
        for (int i = head[u]; i; i = G[i].next)
            if (vis[G[i].to] != clc) {
                pre[G[i].to] = pre[u] + 1;
                vis[G[i].to] = clc; Q.push(G[i].to);
            }
    }
    return pre[u];
}

int main(void) {
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    read(n); read(m);
    for (int i = 1; i <= m; i++) {
        read(x); read(y);
        AddEdge(x, y);
    }
    for (int i = 1; i <= n; i++)
        if (!pre[i]) ++cnt, dfs(i, 0);
    clc = 0;
    if (~ans)
        for (int i = 1; i <= n; i++)
            dis[col[i]] = max(dia(i), dis[col[i]]);
    for (int i = 1; i <= cnt; i++) ans += dis[i];
    printf("%d\n", ans);
    return 0;
}
Orcad 17.2导出PDF原理图终极指南:从Ghostscript安装到带属性书签配置 本文是Orcad 17.2导出高质量PDF原理图的终极指南。针对导出过程中常见的Ghostscript安装报错、软件卡死及版本兼容性问题,提供了详细的解决方案。重点推荐使用Ghostscript 9.53.3版本以确保最佳兼容性,并深入讲解了从安装配置、内存优化到高级书签属性设置的完整流程,帮助硬件工程师稳定、高效地生成带完整器件属性和导航书签的PDF文档。 阅读详情

相关推荐

TikTok滑块验证码verifyV2逆向实战:从fp生成到captchabody加密的完整流程解析

本文详细解析了TikTok滑块验证码verifyV2的逆向工程全流程,从fp参数生成到captchabody加密机制,涵盖了验证码触发、WASM解密、轨迹模拟等关键技术点。通过实战案例和代码示例,帮助开发者深入理解反爬机制,提升逆向工程能力,应对复杂的验证挑战。

weixin_28568819的博客 477

AcWing 456. 车站分级 (虚拟节点优化二分图边数、拓扑序、差分约束、最长路)

原题链接 思路: 代码: #include<bits/stdc++.h> using namespace std; const int N=2010,M=1e6+10; int n,m,e[M],ne[M],h[N],vis[N],dist[N],idx,w[M],d[N]; void add(int a,int b,int c){ e[idx]=b,ne[idx]=h[a],w[idx]=c,h[a]=idx++; d[b]++; } vector<int&g

菱形继承 343

比较几款国际主流的电子元器件及物料清单管理软件 – 工具汇总

Arenasolution 老牌的基于云计算物料清单管理软件,bom.com就是他们家的,10天免费试用,功能被分成4个不同的产品, 和传统ERP功能上有重叠,偏向于物流生产规划,一定程度可以取代ERP的生产规划模块,平均价格70美元/月/席位。网页客户端,不支持离线   SiliconExpert 曾经的老牌物料清单管理软件,后被Arrow 收购,14天免费试用,功能被分成4个不同的产品

u012062784的专栏 7235

[二分图 图的直径] Codeforces 542E VK Cup 2015 - Round 3 E.Playing on Graph

存在奇环就一定无解。 对于一个二分图,最长链为这个图的直径。 将所有连通块的直径相加 #include #include #include #include using namespace std; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; if (p1==p2) { p2=(p1=buf)+fre

雯舞 702

Zoom AI 技术架构研究:联合式方法与多模态集成

通过 Zoom AI 开放平台,企业可以自定义 AI 模块 (如法律合规审查、客户反馈分析),扩展应用场景。这种开放平台策略使企业能够根据自身需求定制 AI 功能,满足特定业务需求。

shao.bing的专栏 1317

IFIX5.8在Win10系统下的安装避坑指南

本文提供了IFIX5.8在Windows 10系统下的详细安装教程与避坑指南。针对常见的驱动缺失、UAC拦截及兼容性报错等问题,文章从安装前准备、分步安装流程到安装后配置与驱动修复,给出了系统性的解决方案,帮助工控从业者顺利完成部署。

f6g7h8i9j的博客 364

Codeforces --Beautiful Graph(二分图+并查集+dfs优化+快速幂)

思路: 给每个点赋值(1,2,3)种的任意一个数,并保证相邻两个节点之和为奇数 由此可以推出:对每一个连通块中的任意一个奇数结点,都有两种赋值可能(1或3),统计每个连通块中的奇数(cnt1)和偶数(cnt2)顶点的个数,只考虑奇数结点的时候有2cnt12^{cnt1}2cnt1种,奇数偶数结点互换后有2cnt22^{cnt2}2cnt2,那么总的方案数就有2cnt1+2cnt22^{cnt1}+2^{cnt2}2cnt1+2cnt2种。 注意: 图不连通的时候,总方案数应为所有连通块的方案数累乘 当某..

不爱吃鱼的猫丶的博客 362

KALI虚拟机挂代理教程

需要你本地挂了代理,然后通过虚拟机连接本机代理端口,不说废话了,直接说怎么做了。 1.查看选项设置中自己的小飞机的本地端口是多少:(默认是1080) 2.本机win+r打开cmd,输入ipconfig查看本地ip,我的本地ip是192.168.0.107: 2.打开kali虚拟机,编辑ProxyChains配置文件: vi /etc/proxychains.conf 3.在文件末尾的ProxyList中添加物理机本地ip和1080端口作为代理地址: 4.保存并退出即可: esc :wq 回车 5.

qq_34853514的博客 3万+

图论--关于最长路的探讨

最短路的求法,有很多,Floyd、Dijkstra、Bellma-Ford,但是我们来思考一下最长路,SPFA和Floyd必然可以跑最长路,一个是DP,一个是基于更新的更新,所以由于这两种特性,决定了他们能够跑最长路,但是最不会被卡的Dijkstra在这里就显得蹩脚了。 为什么?我们来看一下这种情况: 最长路更新的话,最先出队的是1-4边,但是她不能更松弛别人,此时1-4边=3 然后1-3出队,...

日拱一卒,功不唐捐 3490

在 ABAP 平台上搭建 OAuth 2.0 Server:架构、流程、权限与落地实战

摘要:本文为SAP ABAP开发人员提供将ABAP平台配置为OAuth 2.0授权服务器的实战指南。重点介绍两种授权流程(授权码和SAML Bearer)的实现方案,包括核心事务配置(SOAUTH2/SAML2)、授权对象(S_SCOPE)管理以及端点交互规范。通过具体配置清单和三类典型集成场景(第三方Web应用访问OData、企业集成平台调用、BTP应用对接)的落地示例,帮助读者快速构建安全的OAuth 2.0服务架构。文档强调SSL/TLS基础安全、scope最小授权原则以及授权与令牌端点的标准交互模式

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 309

【C2000系列DSP的双向DC-DC电源】基于TMS320F28034的DC-DC项目开发流程

理解DC-DC 双向电源(基于 TMS320F28034)的开发流程,需要从功能拆解、开发步骤、验证 / 测试项

昔时扬尘处 323

二部图------KM算法、匈牙利算法

二分图的概念 二分图又称作二部图,是图论中的一种特殊模型。  设G=(V, E)是一个无向图。如果顶点集V可分割为两个互不相交的子集X和Y,并且图中每条边连接的两个顶点一个在X中,另一个在Y中,则称图G为二分图。  二分图的性质 定理:当且仅当无向图G的每一个回路的次数均是偶数时,G才是一个二分图。如果无回路,相当于任一回路的次数为0,故也视为二分图。 二分图匹配 给定一个二分图G,在...

wang_gongzi的博客 1958

USLE模型(1.2):LS因子的计算

基于USLE的甘南川西北土壤侵蚀研究。准备好30米分辨率的dem。

所有专家都曾始于新手 3481

【CF542E】Playing on Graph

题目大意给出一幅无向图。每一步操作你可以将两个没有边链接的点缩为一个点。问可以缩出的最长链长度。分析这道题一如既往地无从下手。 本来看出了貌似存在奇环答案就为-1,但是不知怎的验证时出错了就否定了这个结论。 其实这道题的关键就在于奇环和偶环。 首先奇环总是会被缩成三角形然后就没法缩了。所以存在奇环的图答案都为-1。 否则这个图必定为二分图。 那么问题就变成了它能缩出的最长链是什么。那么这里

Yves___的专栏 860

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

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

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

Codeforces Round 264 (Div. 2) D题 Gargari and Permutations(建图,有向无环图求最长路)

连一条有向边,容易发现建成的图是一个即有向无环图(DAG),只需要求出DAG的最长路即可。在这里,我们采用拓扑排序和dp进行求解。因此我们可以对所有满足条件的。若在所有的排列中,每一对。,这是一个很小的数。

weixin_74754298的博客 1112

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

codeforces 688c 二分图判断

Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting. Suppose the graph G is given. Subset A of its vertices is called

qiuxueming_csdn 1084

深度学习工具包 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")

二分图(超详细!!!)

0x00 二分图 二分图是一个图,它的顶点可以分为两个独立的集合u和v,这样每一条边(u,v)要么从u到v连接一个顶点,要么从v到u连接一个顶点。换句话说,对于每一条边(u,v),要么u属于u,要么v属于v,或者u属于v,v属于u,也可以说没有边连接同一集合的不同点。 0x01 二分图的判定 可以通过染色法判定二分图。如果可以通过两种颜色将图染色,使得相同集合中的顶点使用相同的颜色,...

coordinate的博客 1万+

二分图最大匹配 增广路径法实现 pku 1469 COURSES

<br />注释在代码里写的很清楚了<br />题目:<br />http://acm.pku.edu.cn/JudgeOnline/problem?id=1469<br /> <br />上代码<br /> #include<stdio.h>#include<memory.h>//分别定义左右最大元素数量#define Left_Max 101#define Right_Max 301//匹配标志!!!!!在DFS遍历中寻找增广路径的时候用,每次在寻找增广路径的时候都要刷新bool visit[Right

野生码农 989

分图的最大匹配与最小路径覆盖

转自: http://stqdd.com/blog/?p=124 二分图的最大匹配与最小路径覆盖 在讲述这两个算法之前,首先有几个概念需要明白: 二分图: 二分图又称二部图,是图论中的一种特殊模型。设G=(V,E)是一个无向图,如果顶点V可以分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同的顶点集(i in A, j in B),

态度决定高度 1323

动态规划法求最大字段和时间复杂度_算法|图论 2W字知识点整理(超全面)

作者:SovietPower✨链接:https://ac.nowcoder.com/discuss/186584来源:牛客网度数序列对于无向图, 为每个点的度数。有 (每条边被计算两次)。有偶数个度数为奇数的点。Havel–Hakimi算法给定一个由有限多个非负整数组成的度数序列,是否存在一个简单图使得其度数序列恰为这个序列。令 为有限多个非负整数组成的非递增序列。 可简单图化当且仅当有穷...

weixin_39628342的博客 760

Codeforces 1220D 思维 数学 二分图基础

由特殊情况推广到一般情况

_int_me的博客 311

Codeforces 542E. Playing on Graph

题目 Solution 可以发现,奇环-&amp;gt;奇环+偶环;偶环-&amp;gt;奇环+奇环或偶环+偶环(单独一条边看作偶环) 所以奇环最终一定会变成三元环,而三元环是无解的,所以奇环是无解的,二分图判一下 然后给每个联通块求一遍直径,加起来即为最终答案 #include&amp;lt;bits/stdc++.h&amp;gt; using namespace std; const int N=1002; struct ...

xumingyang0的博客 259

二部图(二分图)总结

1 二部图 二部图又叫二分图,是图论中的一种特殊模型。设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同的顶点集(i in A,j in B),则称图G为一个二分图。简单来说,如果图中点可以被分为两组,并且使得所有边都跨越组的边界,则这就是一个二分图。准确地说:把一个图的顶点划分为两个不相交子集,使得...

哆啦A瑶的博客 11万+

Codeforces 459E 最长路

bsny在玩一个游戏,这个游戏是在一个带权的有向图中,找一条路径,有个限制条件,这条路径中的权值必须严格增长,也就是如果bsny选择了1到2权值为3的边,那么下一条边的权值必须大于3。 现在问你,bsny最多能找到几条边构成这样的路径。输入 首先输入n, m,表示n个点,m条边. 然后输入m条边,每条边信息由u, v, w组成,表示u到v (1 <= u, v <= n, u != v)有向边

Donald_TY的专栏 699

图论(二) 树与二分图

无圈图:一个图的任何子图都不是圈 树:连通无圈图 树删除的任意一条边都会变成非连通图产品 对树中给定的两个结点的x,y,树中存在唯一一条XY路,因此此路为测地线 若树有Ñ个结点,对条边,则P = N-1,因此,树是最小连通的(满足该关系的不一定是树,树一定满足该关系) 设S为n个正整数组成的序列d1,d2,d3 ... dn,其中,d1 d2 d3 ... dn,并且d1 + d2 + ...

lixiaoguai2017的博客 4774

Codeforces.542E.Playing on Graph(二分图)

题目链接 \(Description\) 给出一个n个点m条边的无向图。 你每次需要选择两个没有边相连的点,将它们合并为一个新点,直到这张图变成了一条链。 最大化这条链的长度,或输出无解。 n<=1000,m<=10000 \(Solution\) 不难发现无解当且仅当存在奇环。 归纳证明:有一个奇环,若与环外一个点合并,这个奇环仍存在;若环内两个点合并,合并两点两边的边数是奇数,合...

weixin_30332241的博客 116
上一篇: [容斥原理][Meet-in-middle][Matrix-Tree定理] SRM551 Div1 Hard SweetFruits
下一篇: [插头DP] BZOJ 2331: [SCOI2011]地板
Vectorxj
博客等级 码龄11年 35粉丝 231原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值