各位大神帮忙看看,为什么RE了

P1808 单词分类

你把数组开大点,把数组放在主函数后面试试
by 汪从文 @ 2017-11-26 17:37:36


主函数外面,刚刚说错了
by 汪从文 @ 2017-11-26 17:37:59


```cpp #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> using namespace std; string s[100001]; bool cmp(string x,string y) { return x<y; } int main() { int n,i,l,ans=0,j,k; char temp; scanf("%d",&n); for(i=1;i<=n;i++) { cin>>s[i]; l=s[i].length(); for(j=0;j<l-1;j++) for(k=j+1;k<l;k++) if(s[i][j]>s[i][k]) { temp=s[i][j]; s[i][j]=s[i][k]; s[i][k]=temp; } } sort(s+1,s+n+1,cmp); for(i=1;i<=n;i++) { if(s[i]!=s[i+1]) ans++; } printf("%d",ans); return 0; } @[dingxingdi](/space/show?uid=65190) 这样就可以AC了 ```
by 汪从文 @ 2017-11-26 17:41:02


@[dingxingdi](/space/show?uid=65190)
by 汪从文 @ 2017-11-26 17:41:25


你RE是因为数组越界了,以后数组尽量多开100,这样比较保险
by 汪从文 @ 2017-11-26 17:42:31


哦哦哦,谢谢谢谢,我去试一试
by dingxingdi @ 2017-11-26 17:52:41


@[AizWallenstein](/space/show?uid=71542) 谢谢你
by dingxingdi @ 2017-11-26 17:53:04


@[dingxingdi](/space/show?uid=65190) 没事,代码AC了吗?
by 汪从文 @ 2017-11-26 18:03:20


@[AizWallenstein](/space/show?uid=71542) 已ac,无超时,谢谢(题目明明告诉n的范围我就开了这么点,以后注意),谢谢
by dingxingdi @ 2017-11-26 18:32:08


|