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…
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…
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…
题目链接:http://poj.org/bbs?problem_id=2503 思路分析: 题目数据数据量为10^5, 为查找问题,使用Hash或Map等查找树可以解决,也可以使用字典树查找. 代码(Map实现): #include <iostream> #include <sstream> #include <string> #include <map> using namespace std; int main() { ], foreignWord[],…
题目链接:http://poj.org/problem?id=3764 题目大意是在树上求一条路径,使得xor和最大. 由于是在树上,所以两个结点之间应有唯一路径. 而xor(u, v) = xor(0, u)^xor(0, v). 所以如果预处理出0结点到所有结点的xor路径和,问题就转换成了求n个数中取出两个数,使得xor最大. 这个之前用字典树处理过类似问题. 代码: #include <iostream> #include <cstdio> #include <cst…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=230 题意:给你许许多多的木棍,没条木棍两端有两种颜色,问你在将木棍相连时,接触的端点颜色必须相同,是否能把它们都连起来 思路:很明显的欧拉路径,但题目给的字符串数据很大,得用字典树存取. 代码如下: #include "stdio.h" #include "string.h" #include "stdlib.h" #define N…