早教吧作业答案频道 -->其他-->
为什么ACM-ICPC通过不了?DescriptionMaybethereare750,000wordsinEnglishandsomewordsareprefixofotherwords,forexample:theword"acm"canbetreatasoneprefixof"acmicpc".What'smore,mostofsuchpairsofwordshaverelationshipbe
题目详情
为什么ACM-ICPC通过不了?
Description
Maybe there are 750,000 words in English and some words are prefix of other words,for example:the word "acm" can be treat as one prefix of "acmicpc".What's more,most of such pairs of words have relationship between them.Now give you a dictionary,your work is to tell me how many such pairs.
There may be other characters in the word,for example '_','-',and so on.
Pay attention that 'A' and 'a' are not the same character!
Input
In the first line of the input file there is an Integer T,which means the number of test cases.Followed by T test cases.
For each test case,in the first line there is an integer N(0next = NULL;
p = head;
while(p!=NULL) {
s = p->next;
while(s!=NULL) {
flag = 1;
t = 0;
while(p->ch[t]!='\0'&&s->ch[t]!='\0') {
if(p->ch[t]!=s->ch[t]) {
flag = 0;
break;
}
t++;
}
if(flag) k++;
s = s->next;
}
p = p->next;
}
if(k>11519) {
*(l+j) = k%11519;
}
else *(l+j) = k;
}
for(i=0;i
Description
Maybe there are 750,000 words in English and some words are prefix of other words,for example:the word "acm" can be treat as one prefix of "acmicpc".What's more,most of such pairs of words have relationship between them.Now give you a dictionary,your work is to tell me how many such pairs.
There may be other characters in the word,for example '_','-',and so on.
Pay attention that 'A' and 'a' are not the same character!
Input
In the first line of the input file there is an Integer T,which means the number of test cases.Followed by T test cases.
For each test case,in the first line there is an integer N(0next = NULL;
p = head;
while(p!=NULL) {
s = p->next;
while(s!=NULL) {
flag = 1;
t = 0;
while(p->ch[t]!='\0'&&s->ch[t]!='\0') {
if(p->ch[t]!=s->ch[t]) {
flag = 0;
break;
}
t++;
}
if(flag) k++;
s = s->next;
}
p = p->next;
}
if(k>11519) {
*(l+j) = k%11519;
}
else *(l+j) = k;
}
for(i=0;i
▼优质解答
答案和解析
不知道ACM是否会对时间复杂度和空间复杂度有要求,我觉得你的程序是没错,也没曲解题意,但是算法效率实在不敢恭维.或许是测试时输入了大量的数据,结果你的程序超时或者内存溢出了
看了 为什么ACM-ICPC通过不...的网友还看了以下:
《伦敦协会海上运输货物保险条款》将基本险的保险责任分为( )。A.I.C.C、F.P.A.和W.A. 2020-05-22 …
《伦敦协会海上运输货物保险条款》将基本险的保险责任分为( )。A. I.C.C、F.P.A.和W.A 2020-05-22 …
《伦敦协会海上运输货物保险条款》将基本险的保险责任分为( )。A.I.C.C、F.P.A.和W.A. 2020-05-22 …
下列词语中字的读音正确的一组是A.弓缴(jiǎo)荆杞(qǐ)旧醅(pēi)万乘(shèng)之势 2020-07-16 …
设A、B、C为事件,P(ABC)>0,如果P(AB|C)=P(A|C)P(B|C),则()A.P( 2020-07-20 …
选出下列各组词语中划线的字读音全都正确的一项是A.瑰丽(guī)婀娜(nuó)隽秀(jùn)汨罗江( 2020-11-13 …
已知玉米胚乳有色至少受3对基因控制,一是基本色泽基因C/c,一是紫色基因P/p,P表现紫色,p表现红 2020-11-24 …
下列各项中字音不正确的一项是:()A.捅(tǒng)娄子熨(wèi)平太尉(wèi)B.慰(wèi) 2020-12-02 …
A.陡峭(qiào)匀称(chèn)纯朴(pǔ)B.开拓(tuò)忧郁(yù)充沛(pèi)C.参天 2021-01-13 …
在资金时间价值计算时,i和n给定,下列等式中正确的有().A.(F/A,i,n)=[(P/F,i,n 2021-01-14 …