Strring Sort - challenge

Sir csn u pls tell what is the problem in this problemn coz it does not pass all test cases in STRRING SORT CHLLLENGE
#include
#include
#include
using namespace std;
bool compare (string a , string b)
{
if(a[0]!=b[0])
{
return a<b;
}
else
{
return a.length()>b.length();
}
}
int main() {
int n;
cin>>n;
cin.get();
string s[n];
for(int i=0;i<n;i++)
{
getline(cin,s[i]);
}
sort(s,s+n,compare);
for(int i=0;i<n;i++)
{
cout<<s[i]<<endl;
}
return 0;
}