UVa10129 Play on Words 并查集判断连通+欧拉通路

Docker拉取ubuntu22.04镜像使用ROS2 humble及仿真工具可视化进行导航 Docker中安装Ubun22以及ROS,gazebo可视化等 阅读详情

                                                 10129 Play on Words
    Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve
it to open that doors. Because there is no other way to open the doors, the puzzle is very important
for us.
    There is a large number of magnetic plates on every door. Every plate has one word written on
it. The plates must be arranged into a sequence in such a way that every word begins with the same
letter as the previous word ends. For example, the word ‘acm’ can be followed by the word ‘motorola’.
Your task is to write a computer program that will read the list of words and determine whether it
is possible to arrange all of the plates in a sequence (according to the given rule) and consequently to
open the door.


Input
    The input consists of T test cases. The number of them (T) is given on the first line of the input file.
Each test case begins with a line containing a single integer number N that indicates the number of
plates (1 <= N <= 100000). Then exactly N lines follow, each containing a single word. Each word
contains at least two and at most 1000 lowercase characters, that means only letters ‘a’ through ‘z’ will
appear in the word. The same word may appear several times in the list.
Output
    Your program has to determine whether it is possible to arrange all the plates in a sequence such that
the first letter of each word is equal to the last letter of the previous word. All the plates from the
list must be used, each exactly once. The words mentioned several times must be used that number of
times.
    If there exists such an ordering of plates, your program should print the sentence ‘Ordering is
possible.’. Otherwise, output the sentence ‘The door cannot be opened.’


Sample Input
3

2
acm
ibm
3
acm
malform
mouse
2
ok
ok


Sample Output
The door cannot be opened.
Ordering is possible.
The door cannot be opened.



不管是无向图还是有向图,首先要保证图的连通性,用DFS判连通或者用并查集都可以

在欧拉通路中,除了起点和终点外,其他点的度数应该是偶数。

如果一个无向图是连通的,且最多只有两个奇点,则一定存在欧拉道路。如果有两个奇点,则必须从一个奇点出发,另一个奇点终止;

如果奇点不存在,则可以从任意点出发,最终一定会回到该点(欧拉回路)。

有向图类似:最多只能有两个点的入度不等于出度,而且必须是其中一个点的出度恰好比入度大1(把它作为起点),另一个的入度比出度大1(把它作为终点)。

当然,前提条件是:在忽略边的方向后,图必须是连通的



#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

const int maxn = 26, lim = 1000;
int T, N;
char s[lim + 10];
vector<int> G[maxn + 10], Gr[maxn + 10];
int f[maxn + 10];

int getf(int x) {
	return x == f[x] ? x : f[x] = getf(f[x]);
}

void Merge(int x, int y) {
	int u = getf(x), v = getf(y);
	if (u != v) {
		if (u < v) {
			f[v] = u;
		}
		else {
			f[u] = v;
		}
	}
}

int abs(int x) {
	return x < 0 ? -x : x;
}

int main()
{
	cin >> T;
	while (T--) {
		scanf("%d", &N);
		for (int i = 0; i < 26; i++) {
			G[i].clear();
			Gr[i].clear();
		}
		for (int i = 0; i < 26; i++) {
			f[i] = i;
		}
		set<int> ss; //用于去重保存节点
		for (int i = 0; i < N; i++) {
			scanf("%s", s);
			int lens = strlen(s);
			int pre = s[0] - 'a', nex = s[lens - 1] - 'a';
			ss.insert(pre);
			ss.insert(nex);
			Merge(pre, nex);
			G[pre].push_back(nex); //邻接表保存出度信息
			Gr[nex].push_back(pre); //逆邻接表保存入度信息
		}
		if (N == 1) {
			puts("Ordering is possible.");
			continue;
		}
		set<int> ans;
		for (set<int>::iterator i = ss.begin(); i != ss.end(); i++) {
			ans.insert(getf(*i));
		}
		//判断最后是不是只有一个集合,即是否连通
		if (ans.size() > 1) {
			puts("The door cannot be opened.");
			continue;
		}
		int cnt = 0, cnts = 0, cnte = 0;
		for (set<int>::iterator i = ss.begin(); i != ss.end(); i++) {
			int out = G[*i].size(), in = Gr[*i].size(); //debug
			if (in != out) {
				if (in - out == 1) {
					cnte++;
				}
				if (out - in == 1) {
					cnts++;
				}
				cnt++;
			}
		}

		//没有入度不等于出度的点
		if (cnt == 0) {
			puts("Ordering is possible.");
			continue;
		}
		
		if (cnt > 2 || cnts > 1 || cnte > 1 || cnts + cnte != cnt) { //debug
			puts("The door cannot be opened.");
		}
		else {
			puts("Ordering is possible.");
		}
	}
	return 0;
}



DeepSeek 赋能太空探索:从轨道优化到星际开拓的 AI 革命 随着人工智能技术蓬勃发展,DeepSeek 在太空探索领域展现出巨大应用潜力。本文深入剖析 DeepSeek 技术核心,包括低功耗运算、开源生态等优势,阐述其与传统航天技术的差异。从航天器自主控制、深空探测、载人航天等关键环节,结合实时轨道调整、故障诊断修复等实例,揭示 DeepSeek 对航天任务效率与安全性的提升作用。同时探讨其应用面临的太空环境适应、伦理安全等挑战,展望技术演进方向及与前沿技术融合前景,展现 DeepSeek 为人类太空探索带来的变革与深远意义。 阅读详情

相关推荐

告别TI官网迷路!手把手教你用C2000Ware为TMS320F28027搭建Proteus仿真工程模板

本文详细指导如何使用C2000Ware为TMS320F28027搭建Proteus仿真工程模板,帮助DSP开发者快速上手。从资源获取、工程目录设计到关键文件配置,再到CCS与Proteus的联调技巧,全面解析仿真工程搭建的每个步骤,特别适合初学者和工程师参考。

weixin_42715608的博客 477

计蒜客习题:布设光纤

问题描述 蒜国有 n 座基站,现在蒜头君想给基站之间布设光纤,使得任意两座基站都是连通的,光纤传输具有传递性,即如果基站 A 和基站 B 之间有光纤,基站 B 和基站 C 之间有光纤,则基站 A 和基站 C 也是连通的,可以通过中间基站 B 来完成传输。 不同的基站之间布设光纤的费用是不同的,现在蒜头君知道了任意两座基站之间布设光纤的费用,求问如何布设,可以使得任意两座基站都是连通的,...

LiuKairui的博客 1212

DeepMD-kit描述子机制解析:从原子坐标到不变性特征

本文深入解析DeepMD-kit描述子机制,详细阐述如何将原子坐标转换为具有平移、旋转和排列不变性的特征表示。探讨了se_e2_a、se_e3等不同描述子的适用场景及性能优化技巧,帮助读者掌握这一关键技术在分子模拟中的应用实践。

weixin_42520661的博客 346

检查网络(并查集)

题目要求: 给定一个计算机网络以及机器的双向连线列表,每一条连线允许两端的计算机进行直接的文件传输,其他计算机间若存在一条连通路径,也可以进行间接的文件传输,请写程序判断,任意指定两台计算机,它们之间是否可以进行文件传输? 输入要求: 输入由若干组测试数据组成。对于每一组测试数据,第1行包含一个整数N( 当N为0时,表示全部测试结束,不要对该数据做任何处理。 输出要求: 对每一组C开头

A place to record sth. 1445

Cadence Allegro PCB文件对比实战:3分钟搞定两份设计差异(附颜色标注技巧)

本文详细介绍了如何高效使用Cadence Allegro的Design Compare功能进行PCB文件差异对比。通过实战工作流,可在3分钟内精准定位并理解两份设计在布局、布线、元件等方面的关键差异,并分享了自定义颜色标注技巧,帮助工程师快速聚焦重要修改,提升设计评审与团队协作效率。

weixin_29248653的博客 390

VisionPro 9.0 QuickBuild里用C#脚本调用Halcon 23.11模型,保姆级图文配置流程

本文详细介绍了如何在VisionPro 9.0 QuickBuild环境中使用C#脚本调用Halcon 23.11深度学习模型,提供从环境配置到模型集成的保姆级图文教程。重点解决图像格式转换、许可证配置等工业视觉检测中的常见问题,帮助开发者快速实现高效、稳定的视觉检测流水线部署。

weixin_27027459的博客 445

例题6-16 UVA10129 Play on Words(34行AC代码)

紫书刷题进行中,题解系列【GitHub|CSDN】 例题6-16 UVA10129 Play on Words(34行AC代码) 题目大意 能否将n个单词顺序连接,其中每个单词的最后一个字母等于它后序单词的首字母(类似词语接龙)。其中单词可以重复。 思路分析 如果将26个小写字母作为图的顶点,每个单词作为边(比如one作为定点o和e的边),那么问题等价于是否存在欧拉回路或通路,在保证**图是连通(...

努力做个书呆儿 692

告别CANoe?手把手教你用Python+PCAN搭建汽车诊断脚本(附完整代码)

本文详细介绍了如何利用Python和PCAN硬件搭建高性价比的汽车诊断自动化方案,替代昂贵的CANoe工具。通过开源库python-can和udsoncan实现UDS诊断协议,涵盖硬件选择、环境配置、核心功能实现及性能优化,附完整代码示例,助力开发者快速构建诊断脚本。

weixin_42551227的博客 381

UVa 10129 Play on Words

好久不谢d

kzzhr 937

海康威视iVMS-8700综合安防管理平台 文件读取漏洞复现

HIKVISION iVMS 综合安防管理平台download接口处存在任意文件读取漏洞,攻击者通过构造token绕过身份认证,读取服务器中的目录信息与敏感文件。使系统处于极不安全的状态。

0xSec 3321

78.在 Vue3 中使用 OpenLayers 实现地图地点搜索定位功能

本文详细介绍了如何在 Vue3 中集成 OpenLayers,实现地图地点搜索和定位功能。Vue3 项目环境的搭建与依赖安装。使用语法实现地图初始化和控件集成。通过 OpenLayers 的 Popup 和 Geocoder 插件,实现地址搜索和定位。希望这篇博文能帮助你快速掌握 Vue3 与 OpenLayers 的集成技术。如果在使用过程中遇到问题,欢迎在评论区留言讨论,或者参考 OpenLayers 官方文档获得更多帮助。注意。

小彭的博客 1871

UVa10129 例题 6-16 单词(Play On Words)

原题链接: UVa-10129 题目大意:   输入n(n 解题思路:  可以根据紫书后面提供的思路进行解决。将单词的首尾字母当做点,每个单词当做边。然后这道题就变成了一个图是否存在欧拉通路。要解决欧拉通路问题有两种方法一种是DFS,另一种是利用并查集。我用的是前一种方法(因为并查集我并不会┑( ̄Д  ̄)┍)。  思路也是和紫书上的一样的,先判断底图(把有向图变成无向图)是否

Miracle42的博客 1461

【RT-DETR涨点改进】独家Conv改进篇 | 来自TIP 2024顶刊| 引入 DEConv细节增强卷积模块, 能够恢复更多细节信息,提升小目标检测精度、含多种不同模型改进点

本文提出了一种细节增强卷积(DEConv)模块,通过融合多种差异卷积(CDC、ADC、HDC、VDC)来增强图像特征表示能力,特别在边缘和纹理细节提取方面表现突出。该模块采用重参数化技术,在不增加计算成本的情况下,将先验信息融入常规卷积层,显著提升了RT-DETR模型在模糊或遮挡场景下的目标检测精度。实验验证了DEConv在多种骨干网络(ResNet18/50、HGNet等)中的有效性,为实时目标检测系统提供了轻量高效的改进方案。

Ai缝合怪、助力小伙伴高效发论文 464

Play on Words,UVA 10129——求欧拉回路/欧拉通路

欧拉

fsdcyr 805

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

UVa--10129 Play on Words(欧拉通路)

UVa 10129题意n个单词,是否可以把它们排成一个序列,是的每个单词的第一个字母的前一个单词的最后一个字母相同。输入中可以有重复单词。题解把字母看作结点,单词看作边,那么这题便是判断构成的有向图中是否存在欧拉通路。 有向图存在欧拉通路需要满足两个条件: 1. 它的无向图连通; 2. 顶点度数满足:顶点的入度等于出度,或者有两个顶点,一个入度比出度大1,另一个出度比入度大1,其他顶点入度等于

许少y 598

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

UVa10129 Play on Words (欧拉通路)

题目链接 Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very...

Happig的博客 314

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

UVA 10129 Play on Words (欧拉通路)

本文链接:http://www.cnblogs.com/Ash-ly/p/5398627.html 题意:   输入N(N <= 100000)个单词,是否可以把所有这些单词排成一个序列,使得每个单词的第一个字母和上一个单词的最后一个字母相同(例如:acm,malform,mouse)。每个单词最多包含 1000 个小写字母。输入中可以有重复的单词。 思路:   把一个字母...

dimaishu7553的博客 119

uva 10129 Play on Words

把每个单词的第一个和最后 一个字符作为一条有向边,26个字母作为节点构造有向图,如果该图中存在欧拉回路或者欧拉路,就符合题设要求,反之不符合要求,可以先用并查集判断有向图是不是弱连通的,然后把所有入度等于出度的点取出来,如果取出来的点的个数为0,说明存在欧拉回路,如果取出来的点的个数不等于0也不等于2,肯定没有欧拉路存在了,如果取出来的点的个数等于2,还要判断这两个点的入度和出度,是不是一个入度比

皓首不倦 不负少年 671

Play on Words UVA - 10129 (欧拉回路)

题目: Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very...

titi2018815的博客 215

uva 10129 Play On Words(单词)求欧拉回路或欧拉通路

题目:输入n个单词,是否可以把这些所有单词排成一个序列,使得每个单词的第一个字母和上一个单词的最后一个字母想同。 有向图欧拉回路:1,图连通.2,所有定点入度等于出度 有向图欧拉通路:1,图连通.2,仅有两个奇度定点,其中一个入度比出度大1,另一个定点出度比入度大1 思路:可以把一个单词看作一条边,单词的首尾两个字母为定点,建立无向图(即G[u][v]=G[v][u]=1),因为欧拉

时间杀手Time的博客 477

UVA-10129 Play on Words

题目链接:https://vjudge.net/problem/UVA-10129 输入的字符串首尾相连,可以看成一个26个字母组成的有向图,如果可以找到一条欧拉通路,则有解 先判断出入度是否符合,再判断是否连通,都满足则有欧拉通路 #include #include #include #include #include using namespace std; typedef long l

wl16wzl的博客 240

uva - 10129 Play on Words(欧拉通路)

Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very important for us. There is a large number of magnetic plates

SsteelXD的博客 295

例题6-16 单词(Play On Words, UVa 10129)

裸的有向图判欧拉通路问题。。 所有点入度 = 出度则存在欧拉回路,度数不等点恰好为2,其中一点且入度 - 出度 = 1,则为欧拉通路。#include #include #include #include #include #include #include #include #include #include #include #include #include #i

%%% 480

Uva10129 Play on Words【dfs解欧拉回路】【例题6-16】

dfs解决欧拉回路。dfs判断时要灵活应用!

GuoZLH的博客 764

uva 10129 - Play on Words

欧拉回路的一道不错的题目。(顺便总结下欧拉回路) 欧拉道路:能从无向图中的一个结点出发走出一条道路,每条边恰好经过一次。 如果一个无向图是连通的,且最多只有两个奇点(点的度数为奇数的点),则一定存在欧拉道路。 如果有两个奇点,则必须从其中一个奇点出发,另一个奇点终止; 如果奇点不存在,则可以从任意点出发,最终一定会回到该点。(称为欧拉回路)。 奇点不可能为奇数,一条边提供两个度,起点,终

catfish的专栏 761

UVA 10129 Play on Words

UVA 10129 Play on Words题目大意:判断首字母与末尾字母形成的若安路是否形成欧拉通路解题思路:判断是否连通,然后判断度数是否为偶数(起点和终点入度和出度可以相差1)#include <stdio.h> #include <iostream> #include <string.h> #include <stack> using namespace std; stack<int> s

ZeroLH00的博客 304
上一篇: UVa 10305 Ordering Tasks 拓扑排序
下一篇: hdu1024 Max Sum Plus Plus dp
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值