早教吧作业答案频道 -->其他-->
为什么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通过不...的网友还看了以下:
11春季人体生理学学习周期1.评价肺通气功能较好的指标是()A.肺活量B.最大通气量C.每分通气量 2020-04-26 …
交警是负责( )工作的人民警察。A.维护交通安全和交通秩序B.处理交通事故C.进行交通管制D.进行交 2020-05-19 …
交通安全管理工作的目的是( )A.预防交通事故B.查处交通事故C.保证交通安全D.保证交通畅通 2020-05-19 …
一辆汽车在平直公路上做匀变速直线运动,公路边每隔15米有一棵树,汽车通过A,B相邻的两棵树用了3s 2020-05-20 …
道路交通信号包括( )。 A.交通信号灯B.交通标志C.交通标线和交通警察的指挥## 2020-05-22 …
道路交通信号包括( )。 A. 交通信号灯B. 交通标志C. 交通标线和交通警察的指挥D. 以上都是 2020-05-22 …
下列不属于道路交通信号的是( )。A.交通信号灯B.交通标志C.交通标线和交通警察的指挥D.卫星定位 2020-05-22 …
有关解决城市交通问题的叙述,错误的是()A.城市交通面临的主要问题有交通线路拥阻和交通环境污染.B 2020-06-22 …
您可能在电视上经常听到“两岸三通”的字眼,请看下列选项中属于“三通”的是()A.通邮、通航、通电B. 2020-11-07 …
40℃时,在氨-水体系中不断通入CO2,各种离子的变化趋势如图所示.下列说法不正确的是()A.在pH 2020-12-17 …