题意: 如上图所示,将一个字符串进行分割,反转等操作后不同字符串的个数: 例如字符串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: 6478   Accepted: 1871 Description RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The…
http://poj.org/problem?id=3007 题意 :给你一个字符串,让你无论从什么地方分割,把这个字符串分成两部分s1和s2,然后再求出s3和s4,让你进行组合,看能出来多少种不同的形式. 思路 :记得以前的时候就听他们讨论这道题,说是用map做会超时,所以我直接就没用map....但是做这道题实在是太波折了,昨天晚上改了一晚上都不对,就是不知道哪里出了问题,今早上又改,改来改去才知道原来我new node后边缺了个括号,我很懵懂,我记得不用括号也行啊,而且我看到一个AC的代码…
题目:http://poj.org/problem?id=3007 题意:按照图示的改变字符串,问有多少种..字符串.. 思路:分几种排序的方法,,刚开始用map 超时(map效率不高啊..),后来搜了一下题解,用二叉排序树... 先贴AC代码: #include <iostream> #include <cstring> #include <algorithm> using namespace std; typedef struct tree { ]; struct…
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…
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…
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…
http://poj.org/problem?id=3007 第一次用STL做的,TLE了,自己构造字符串哈希函数才可以.. TLE代码: #include <cstdio> #include <algorithm> #include <iostream> #include <string> #include <map> using namespace std; int main() { int n; scanf("%d",&…
Organize Your Train part II Time Limit: 1000MS Memory Limit: 65536K 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 Figure 1.…