Organize Your Train part II Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6478   Accepted: 1871 Description RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The…
题意: 如上图所示,将一个字符串进行分割,反转等操作后不同字符串的个数: 例如字符串abba:可以按三种比例分割:1:3:2:2:3:1 部分反转可以得到如下所有的字符串: 去掉重复可以得到六个不同的字符串,输出6: 解题思路: 此题用反转函数reverse比较方便,然后就和模拟差不多,要列出所有情况,把不同的字符串保存在一个字符数组中,每次得到一个字符串都和该字符数字中的每一个比较,如果都不相同,把它存入字符数组:. 直接看代码吧: //Organize Your Train part II…
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6700 Accepted: 1922 Description RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The layout of the lines is shown in…
题目:http://poj.org/problem?id=3007 题意:按照图示的改变字符串,问有多少种..字符串.. 思路:分几种排序的方法,,刚开始用map 超时(map效率不高啊..),后来搜了一下题解,用二叉排序树... 先贴AC代码: #include <iostream> #include <cstring> #include <algorithm> using namespace std; typedef struct tree { ]; struct…
http://poj.org/problem?id=3007 题意 :给你一个字符串,让你无论从什么地方分割,把这个字符串分成两部分s1和s2,然后再求出s3和s4,让你进行组合,看能出来多少种不同的形式. 思路 :记得以前的时候就听他们讨论这道题,说是用map做会超时,所以我直接就没用map....但是做这道题实在是太波折了,昨天晚上改了一晚上都不对,就是不知道哪里出了问题,今早上又改,改来改去才知道原来我new node后边缺了个括号,我很懵懂,我记得不用括号也行啊,而且我看到一个AC的代码…
Organize Your Train part II Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7561   Accepted: 2194 Description RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The…
Organize Your Train part II Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8787   Accepted: 2490 Description RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The…
Phone List 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue listed these numbers: Emergency 911 Alice 97 625 999…
http://poj.org/problem?id=2513 题意: 给定一些木棒,木棒两端都涂上颜色,求是否能将木棒首尾相接,连成一条直线,要求不同木棒相接的一边必须是相同颜色的. 思路: 题目很明显的是欧拉道路的问题. 欧拉道路的关键是: ①图是连通的. ②最多只能有两个奇点.(不能只存在一个奇点) 本来是想用map映射的,但是太多了,比较费时,这里用字典树的话会比较省时,判断图是否连通可以用并查集来完成. #include<iostream> #include<algorithm&…
http://poj.org/problem?id=3007 #include<cstdio> #include<algorithm> #include<cstring> #define maxn 600000 using namespace std; struct node { ]; node *next; }; int ans; node *hash[maxn]; void insert(char s[]) { int k=strlen(s); ; ; i<k…