(Your)((Term)((Project))) Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2912   Accepted: 1084 Description You have typed the report of your term project in your personal computer. There are several one line arithmetic expressions in yo…
(Your)((Term)((Project))) Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3353 Accepted: 1256 Description You have typed the report of your term project in your personal computer. There are several one line arithmetic expressions in your r…
Description You have typed the report of your term project in your personal computer. There are several one line arithmetic expressions in your report. There is no redundant parentheses in the expressions (omitting a pair of redundant matching parent…
题目传送门 /* 题意:第i个人选择第a[i]个人,问组成强联通分量(自己连自己也算)外还有多少零散的人 有向图强联通分量-Tarjan算法:在模板上加一个num数组,记录每个连通分量的点数,若超过1,则将连通点数相加 用总点数-ans则是零散的点 详细解释:http://www.bubuko.com/infodetail-927304.html */ #include <cstdio> #include <cstring> #include <algorithm> #…
Term Project Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ID: 651164-bit integer IO format: %lld      Java class name: Main     解题:强连通分量  #include <bits/stdc++.h> using namespace std; ; struct arc{ int t…
题目链接:http://poj.org/problem?id=1686 思路分析:该问题为表达式求值问题,对于字母使用浮点数替换即可,因为输入中的数字只能是单个digit. 代码如下: #include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <string> using namespace…
题目链接:http://poj.org/problem?id=2406 题意:确定字符串最多是多少个相同的字串重复连接而成的 思路:关键是找到字符串的最小循环节 code: #include <cstdio> #include <cstring> ; char s[MAXN]; int next[MAXN]; void GetNext() { int len = strlen(s); ; ; next[] = -; while (i < len) { == j || s[i]…
Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15900   Accepted: 5494 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the…
题目:http://poj.org/problem?id=3080 Sample Input 3 2 GATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 3 GATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATA GATACTAGATACTA…
题目链接: http://poj.org/problem?id=1509 题意: 求循环字符串的最小表示. 分析: 浅析"最小表示法"思想在字符串循环同构问题中的应用 判断两字符串是否是循环同构的过程就是在求字符串的最小表示,即如果两个字符串是循环同构的,那么当前两指针i=M(s1) 且j=M(s2) 的时候,一定可以得到u[i→i+s1−1] = w[j→j+s2−1] , 所以我们把给定序列看成两个循环同构的字符串,然后求一下最小表示就好了. 代码: #include<cst…
题目大意: 给定n个字符串,求出现在不小于k/2个字符串中的最长子串. 二分找对应子串长度的答案,将所有字符串链接成一个长字符串求后缀数组,记录每一个位置本属于第几个字符串,利用height查询的时候, 根据记录的位置不断判断是否出现重复的字符串是在同一个字符串内的 #include <cstdio> #include <cstring> #include <vector> #include <iostream> using namespace std; t…
给出两个长度小于1000的字符串,有三种操作,插入一个字符,删除一个字符,替换一个字符. 问A变成B所需的最少操作数(即编辑距离) 考虑DP,可以用反证法证明依次从头到尾对A,B进行匹配是不会影响答案的 令dp[i][j]表示A[i]~[lenA]变成B[j]~[lenB]的最优解. 如果把B[j]插入到A[i]前,dp[i][j]=dp[i][j+1]+1 如果删除A[i],dp[i][j]=dp[i+1][j]+1. 如果A[i]==B[j], dp[i][j]=dp[i+1][j+1].…
#include<iostream>//写字符串的题目可以用这种方式:str[i][j] &str[i] using namespace std; int main() {int n,m,i,j,num,a[101],b[101],t,k; char str[101][51]; cin>>n>>m; for(i=0;i<m;i++) { cin>>str[i]; num=0; for(j=0;j<n-1;j++) for(k=j+1;k&…
Life Forms Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 16223   Accepted: 4763 Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, e…
                                                                                                  Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 38038   Accepted: 15740 Description Given two strings a and b we define a*b t…
Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20695   Accepted: 9167 Description The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousa…
题意:给出nn(1≤n≤50,1≤n≤50) 个病毒DNA序列,长度均不超过20.现在给出一个长度不超过1000的字符串,求至少要更换多少个字符, 才能使这个字符串不包含这些DNA序列. 析:利用前缀来做好状态转移. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #…
Period Time Limit: 3000MS Memory Limit: 30000K Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for e…
POJ1056 给定若干个字符串的集合 判断每个集合中是否有某个字符串是其他某个字符串的前缀 (哈夫曼编码有这个要求) 简单的过一遍Trie就可以了 #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<vector> #include<queue> #include<algor…
题意:给你一个字符串,求这个字符串到第 i 个字符为止的重复子串的个数. 解法:判断重复子串的语句很重要!!if (p && i%(i-p)==0) printf("%d %d\n",i,i/(i-p)); 我之前一直不是很理解,而实际上多枚举几种情况就好了.若是重复的,那么next[i]肯定是最大值,值余下一个循环节不同:而若不是,next[i]表示的前缀和后缀串的和重叠部分不一样以外的部分就肯定空出来,不能整除的.(P.S.我在说些什么......m(._.)m)…
用记录附加信息的val数组记录次数即可. trie的原理:每个可能出现的字目给一个编号c,那么整个树就是一个c叉树 ch[u][c]表示 节点u走c边过去之后的节点 PS:trie树还有种动态写法,使用指针和动态分配内存代替了连续的ch数组,更加节省内存. Reference:http://blog.csdn.net/architect19/article/details/8966247 #include <cstdio> #include <cstring> #include &…
题意:求子串在文本串中出现了多少次. 解法:使用KMP的next[ ]和tend[ ]数组计数. #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> using namespace std; ,M=; char s[N],ss[M]; int n,m; int next[N];//,tend[M]; void kmp() { memset(next,,sizeof(n…
/* * POJ_1159.cpp * * Created on: 2013年10月29日 * Author: Administrator */ #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> using namespace std; const int maxn = 5005; char str1[max…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=423 Sample Input 3(A-B + C) - (A+(B - C)) - (C-(D- E) )((A)-( (B)))A-(B+C) Sample Output A-B+C-(A+B-C)-(C-(D-E))A-BA-(B+C) 题目大意:给出加减代数表达式,仅由变量(大写字母表示),圆括号,加号 '+', 减号'-'组成,要求去掉多余的括号,但是不能改…
Description 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 Bob 91 12 54 26 In this case, it's not p…
Best Cow Line Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9284   Accepted: 2826 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his…
A POJ 1018 Communication System B POJ 1050 To the Max C POJ 1083 Moving Tables D POJ 1125 Stockbroker Grapevine E POJ 1143 Number Game F POJ 1157 LITTLE SHOP OF FLOWERS G POJ 1163 The Triangle H POJ 1178 Camelot I POJ 1179 Polygon J POJ 1189 钉子和小球 K…
此文转载别人,希望自己能够做完这些题目! 1.POJ动态规划题目列表 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276,1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740(博弈),1742, 1887, 1926(马尔科夫矩阵,求平衡), 1936, 1952, 1953, 1958, 1959, 1962, 1975,…
[1]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740(博弈), 1742, 1887,1926(马尔科夫矩阵,求平衡), 1936, 1952, 1953, 1958, 1959, 1962, 1975, 1989, 2018, 2029,…
]POJ 动态规划题目列表 容易: 1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740(博弈), 1742, 1887, 1926(马尔科夫矩阵,求平 衡), 1936,1952, 1953, 1958, 1959, 1962, 1975, 1989, 2018, 2029,2…