Same code gave first 100 than 0

i submitted the same code twice and first it gave me 100 points and 2nd time 0 why?

code:-
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef vector vi;
typedef pair< int,int> ii;
typedef vector<pair<int, int> > vp;
typedef vector<pair<int, ii> > vpp;
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
bool comp(string a,string b)
{
int z=min((int)a.length(),(int)b.length());
// cout<<z<<endl;
int ans=-1;
for(int i=0;i<z;i++)
{
if(a[i]>b[i])
{
ans=0;
break;
}
else if(a[i]<b[i])
{
ans=1;
break;
}
}
// cout<<ans<<endl;
if(ans==-1)
{
if(a.length()>b.length())
{
return 1;
}
else
{
return 0;
}
}
else
{
if(ans==0)
return 0;
else
return 1;
}
}
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
string ss[1005];
int n;
cin>>n;
for(int i=0;i<n;i++)
cin>>ss[i];
sort(ss,ss+n,comp);
for(int i=0;i<n;i++)
{
cout<<ss[i]<<endl;
}
return 0;
}

Paste your code on coding blocks IDE and share the link here .