Colored Sticks Time Limit: 5000MS   Memory Limit: 128000K Total Submissions: 27134   Accepted: 7186 Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a st…
题目链接:http://poj.org/problem?id=2513 思路很容易想到就是判断欧拉通路 预处理时用字典树将每个单词和数字对应即可 刚开始在并查集处理的时候出错了 代码: #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; int color; #define maxn 26 #define MAX 500010…
Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpoints that touch are of the same color? Input Input is a…
题目:http://poj.org/problem?id=2513 参考博客:http://blog.csdn.net/lyy289065406/article/details/6647445 http://www.cnblogs.com/LK1994/p/3263462.html #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stac…
Play on Words Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4263    Accepted Submission(s): 1384 Problem Description Some of the secret doors contain a very interesting word puzzle. The team…
题意:给出很多很多很多很多个棒子 左右各有颜色(给出的是单词) 相同颜色的可以接在一起,问是否存在一种 方法可以使得所以棒子连在一起 思路:就是一个判欧拉通路的题目,欧拉通路存在:没奇度顶点   或者只有2个奇度顶点 同时要连通   .关键在于给颜色hash和 判断连通性   hash用字典树  连通用并查集 #include<cstdio> #include<iostream> #include<cstring> using namespace std; +; str…
题目大意: 有一堆头尾均有颜色的木条,要让它们拼接在一起,拼接处颜色要保证相同,问是否能够实现 这道题我一开始利用map<string,int>来对颜色进行赋值,好进行后面的并查操作以及欧拉通路的判断,但是map效率太低,超时了 网上看了一遍发现必须得用效率更高的字典树对每个不同的颜色进行赋值 #include <iostream> #include <cstdio> #include <cstring> using namespace std; #defi…
                                                         Colored Sticks Time Limit: 5000MS   Memory Limit: 128000K Total Submissions: 35612   Accepted: 9324 Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored wi…
题目地址:POJ 2001 考察的字典树,利用的是建树时将每个点仅仅要走过就累加.最后从根节点開始遍历,当遍历到仅仅有1次走过的时候,就说明这个地方是最短的独立前缀.然后记录下长度,输出就可以. 代码例如以下: #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h&g…
系统的学习一遍图论!从这篇博客开始! 先介绍一些概念. 无向图: G为连通的无向图,称经过G的每条边一次并且仅一次的路径为欧拉通路. 如果欧拉通路是回路(起点和终点相同),则称此回路为欧拉回路. 具有欧拉回路的无向图G称为欧拉图. 有向图: D为基图连通的有向图,则称经过D的每一条边并且仅一次的路径为有向欧拉通路. 如果该通路是回路,则称为有向欧拉回路. 具有有向欧拉回路的有向图D称为有向欧拉图. 无向图判断欧拉通路:G为连通图,且仅有两个奇度的节点或者无奇度节点. 如果有两个奇度的点,那么这两…