随笔分类 - 动态规划
摘要:1968: Common SubsequenceResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE1s4096K781227StandardA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a subse
阅读全文
摘要:2511: Number triangleResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE1s65536K467233Standard 5 3 4 8 1 2 5 4 3 62 1 7 9 8A number trangle is composed of N(N<=100) line numbers, the i-th line contains i positive integers(<=100). A chess can walk from the top line ...
阅读全文
摘要:矩阵连乘是经典的DP问题。n个矩阵连乘会因为乘的次序问题导致效率差异。这个问题中比较难想的是计算m[][]时的次序,必须保证计算m[i][j]查找m[i][k]和m[k+1][j]时这两个已经计算出来了。这里是根据王晓东的算法书里的想法写的,他用的是Java,必须提醒的就是在用C++时一个蛋疼的数组越界问题。int *p = new int[5];此时p[5] = 10; 就是越界的,但C++为了效率上的考虑华丽地无视了这个越界,编译器并没有义务指出它。更bt的是cout << p[5] << endl; 是正确的,能输出10。但这程序指不定什么时候就诡异得挂了。所以n
阅读全文
摘要:1995: EnergyResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE3s10240K1366357StandardMr. Jojer is a very famous chemist. He is doing a research about behavior of a group of atoms. Atoms may have different energy and energy can be positive or negative or zero, e.g. 18 or -9. Absolute value of energy
阅读全文

浙公网安备 33010602011771号