c语言Time Limit Exceed 该怎么修改啊DescriptionYou still are worried about reading acm English problem, let me tell you a kind of very good method of Memorising Words, the root memory method,.the most interesting of the method is the prefix ro
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 21:56:14
c语言Time Limit Exceed 该怎么修改啊DescriptionYou still are worried about reading acm English problem, let me tell you a kind of very good method of Memorising Words, the root memory method,.the most interesting of the method is the prefix ro
c语言Time Limit Exceed 该怎么修改啊
Description
You still are worried about reading acm English problem, let me tell you a kind of very good method of Memorising Words, the root memory method,.the most interesting of the method is the prefix root. Now there are some English words to remembeand he knows some prefix root;He want to know how many words that can be remembered using each the prefix .in other words,how many words that contain the prefix ,Now to acmer you for help, can you help him?
Input
The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case begins with a line containing a single integer number N that indicates the number of words (1
c语言Time Limit Exceed 该怎么修改啊DescriptionYou still are worried about reading acm English problem, let me tell you a kind of very good method of Memorising Words, the root memory method,.the most interesting of the method is the prefix ro
程序懒得写了,给你两个想法,一个正常的,一个古怪的.
第一个是,不要逐个找,要排序,排序的复杂度低.
第二个,(相当古怪),考虑到最多10个字母,每个字母最多26种情况,而5个bit就是32种情况,10个字母才50个bit,一个单词完全可以用一个64bit整数替换.这样又能快好几倍.
P.S.:你用数组的方式不好,内存很慢,尽量用CPU缓存,[11]宁可改成[16],会快一些.
程序我鼓励自己弄,尤其是ACM这种,基本上就是一个简单想法.