I got Compilation error when I was using STL. I have tried avoid using "using namespace...".. as some have told before, but doesnt' help!
Here' the compilation error in Unix screen (tried to copy all in the screen)
Code: Select all
g++ 10029.cpp
/usr/local/.5.8/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../include/g++-3/std/bastring.:
/usr/local/.5.8/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../include/g++-3/std/bastring.e
/usr/local/.5.8/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../include/g++-3/std/bastring.'
/usr/local/.5.8/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../include/g++-3/std/bastring.'
Code: Select all
#include<iostream>
#include<map>
#include<string>
#include<cstdio>
#define MAXN 25001
using std::cin;
using std::cout;
using std::map;
using std::endl;
using std::string;
typedef map<string, int> Map;
Map dictionary;
int n = 0, fx[MAXN], record = 0;
void readData()
{
string s;
while (cin>>s)
{
dictionary[s] = n++;
}
}
void check (int d, string s1, string s)
{
Map::iterator k ;
k = dictionary.find(s1);
if ( k != dictionary.end())
{
int i = (*k).second;
if (i < d)
if (fx[i] + 1 > fx[d])
{
fx[d] = fx[i] + 1;
if (fx[d] > record) record = fx[d];
}
}
}
void process()
{
int i, j, k, d = 0;
memset(fx, 0, sizeof(fx));
Map::iterator iter;
for (iter = dictionary.begin(); iter != dictionary.end(); iter++)
{
string s = (*iter).first;
fx[d] = 1;
// inserting
for (j = 0; j < s.length(); j++)
{
for (k = 0; k < 26; k++)
{
string temp(1, (char)('a'+k)), s1 = s;
s1.insert(j, temp);
check (d, s1, s);
}
}
// deleting
for (j = 0; j < s.length(); j++)
{
string s1 = s;
s1.erase(j,1);
check(d, s1, s);
}
// changing
for (j = 0; j < s.length(); j++)
{
string s1 = s;
for (k = 0; k < 26; k++)
{
string temp(1, 'a' + k);
s1.erase(j,1);
s1.insert(j, temp);
check(d, s1, s);
}
}
d++;
}
cout<<record<<endl;
}
int main()
{
//freopen("10029.in", "r", stdin);
readData();
process();
return 0;
}
I'm frustrated, pls help
thank friends alot ![/code]