#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long int ll;
string removespl(string s)
{
string rev="";
for(int i=0;i<s.length();i++)
{
if(s[i]!='.' && s[i]!='\'' && s[i]!=':' && s[i]!=';' && s[i]!=',')
{
rev+=s[i];
}
}
return rev;
}
bool compareChar(char & c1, char & c2)
{
if (c1 == c2)
return true;
else if (std::toupper(c1) == std::toupper(c2))
return true;
return false;
}
bool caseInSensStringCompare(std::string & str1, std::string &str2)
{
return ( (str1.size() == str2.size() ) &&
std::equal(str1.begin(), str1.end(), str2.begin(), &compareChar) );
}
int main() {
fastIO;
vector<string>lines;
vector<string>palindromiclines;
// ll N;
// cin>>N;
// for/(int i=0;i<N;i++)
// {
string input;
while(cin>>input)
{
lines.push_back(removespl(input));
}
// }
// reverse(lines.begin(),lines.end());
for(int i=0;i<lines.size();i++)
{
for(int j=i+1;j<lines.size();j++)
{
if(caseInSensStringCompare(lines[i],lines[j]))
{
auto it=find(lines.begin(),lines.end(),lines[i]>lines[j]?lines[j]:lines[i]);
lines.erase(it);
}
}
}
sort(lines.begin(),lines.end());
cout<<lines.size();
for(int i=0;i<lines.size();i++)
cout<<"\n"<<lines[i];
// cout<<endl;
return 0;
}
This code does not pass the test cases, idk why, could someone help me out?