题目链接:poj 2513 Colored Sticks题目大意:有N个木棍,每根木棍两端被涂上颜色。如今给定每一个木棍两端的颜色。不同木棍之间拼接须要颜色同样的端才干够。问最后是否能将N个木棍拼接在一起。解题思路:欧拉通路+并查集+字典树。欧拉通路,每一个节点的统计度,度为奇数的点不能超过2个。并...
分类:
其他好文 时间:
2015-08-21 23:03:31
阅读次数:
216
Picking up Jewels
There is a maze that has one entrance and one exit.
Jewels are placed in passages of the maze.
You want to pick up the jewels after getting into the maze through the entran...
分类:
其他好文 时间:
2015-08-19 11:23:51
阅读次数:
1384
区间dp,切割dp[i][j]的花费和切法无关(无后效性)dp[i][j]表示区间i,j的花费,于是只要枚举切割方法就行了,区间就划分成更小的区间了。O(n^3)看了看四边形不等式,证明太长了。#include //变量不要取成ignore left之类using namespace std;con...
分类:
其他好文 时间:
2015-08-19 00:13:11
阅读次数:
336
Pick-up sticksTime Limit: 3000MSMemory Limit: 65536KTotal Submissions: 11043Accepted: 4119DescriptionStan has n sticks of various length. He throws th...
分类:
其他好文 时间:
2015-08-18 21:00:51
阅读次数:
150
import os import socketimport threadingimport SocketServerSERVER_HOST = 'localhost'SERVER_PORT = 0 #tells the kernel to pick up a port dynamicallyBUF_...
分类:
其他好文 时间:
2015-08-15 22:44:21
阅读次数:
190
http://acm.hdu.edu.cn/showproblem.php?pid=1455题意:几根长度的棍子被分成了很多半。问合成多个长度相同的棍子,棍子长度最小是多少。题解:很明显是dfs。所以我们首先需要找到,这些棍子可能是多长,肯定是最长的棍子的长度到所有棍子长度和之间的某个长度。找到这些...
分类:
其他好文 时间:
2015-08-15 00:08:49
阅读次数:
167
Description
George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sti...
分类:
其他好文 时间:
2015-08-14 21:29:39
阅读次数:
109
这道题有些类似矩阵连乘,就是区间的问题。设dp[i][j]表示从i到j的最小花费,那么dp[i][j]=min{dp[i]
[k]+dp[k][j]+a[j]-[i]}(i
间得时候小区间已经算出来了,所以符合动态规划的自底向上,而且是最优子结构,这道题我把0和木条长度加到了a
数组里面,就是说一共有n+2个点,每两个相邻的点不用切割,初始化为1
代码:
#include
#includ...
分类:
其他好文 时间:
2015-08-12 11:38:55
阅读次数:
94
这题不错,用到了三个知识点,我开始没用字典树,超时了。顺便学习了字典树。
看到了一个不错的题解。
可以用图论中欧拉路的知识来解这道题,首先可以把木棒两端看成节点,把木棒看成边,这样相同的颜色就是同一个节点
问题便转化为:
给定一个图,是否存在“一笔画”经过涂中每一点,以及经过每一边一次。
这样就是求图中是否存在欧拉路Euler-Path。...
分类:
其他好文 时间:
2015-08-06 22:25:27
阅读次数:
239
Pick-up
sticks
Time Limit: 3000MS
Memory Limit: 65536K
Total Submissions: 10949
Accepted: 4085
Description
Stan has n sticks of various length. He throws them one...
分类:
其他好文 时间:
2015-08-05 20:29:23
阅读次数:
139