zoj-1062 下面的程序在本地运行没问题,提交之后runtime error,高手帮忙看看吧

2024-12-26 21:57:01
推荐回答(1个)
回答1:

在本地运行结果没问题,什么也不能说明.
你这代码太过冗杂。看看这个代码
#include
#include
#include
#include // STL sort function
using namespace std;

char map[] = "2223334445556667#77888999#";
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
void visited(char &ch) // visit and format strings
{
if (ch >= 'A' && ch <= 'Z')
ch=map[ch-'A']; // ch equals to its real number
}

int main()
{
int N,i=0,j,flag=0;
string s;
vector stored(100000); // be visited & stored (up to 100,000)
cin>>N;
vector counter(N,1); // stored times

for (; i {
cin>>s;
for (j=0; j {
visited(s[j]);
if (s[j]!='-')
{
stored[i] += s[j];
if (stored[i].length()==3)
stored[i] += '-'; // 487 -[3] 3279
}
}
}
sort(stored.begin(),stored.begin()+N); // Quicker than QuickSort!
// should not used stored.end() !
i=0; j=1;
while (i {
while(stored[i] == stored[j])
{
counter[i]++;
j++;
flag=1;
}
i=j;
j++;
}

if (flag)
for (i=0; i {
if (counter[i]>1)
cout< } // must have { }
else cout<<"No duplicates."<
return 0;
}

希望对你有些帮助。