Continuing the discussion from Why do I get a SIGABRT?:
why my code is getting SIGABRT error[quote=“shubham99, post:1, topic:11341, full:true”]
I am trying to solve this problem but I am getting a SIGABRT error. Please help me in figuring out why .
THANKS IN ADVANCE…
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
while(t--){
ll m,n,i,j,m1;
cin>>m>>n;
vector<ll> p(n+5,1);
if(m>=2)
m1=m;
else
m1=2;
for(i=m1;i<=n;i++){
if(i%2==0&&i>2)
p[i]=0;
if(p[i]){
for(j=2;i*j<=n;j++)
p[i*j]=0;
}
}
for(i=m1;i<=n;i++){
if(p[i])
cout<<i<<endl;
}cout<<endl;
}
return 0;
}
[/quote]
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
vector<int> v(n);
vector<pair<int,int>> rel(n);
for(auto &i : v)
{
cin>>i;
}
vector<int> dup(v);
sort(dup.begin(),dup.end());
set<int> s(v.begin(),v.begin()+n);
if(s.size() == 1)
{
for(int i = 1;i<= n ;i++)
{
cout<<v[0]+i<<" ";
}
cout<<"\n";
}
else
{
rel[0].first = dup[0];
rel[0].second = 0;
for(int i = 1;i<=n;i++){
rel[i].first = dup[i];
if( (i>1) and (dup[i]==dup[i-1])){
//rel[i].first = dup[i];
rel[i].second = rel[i-1].second-1;
}
else
rel[i].second = dup[i]-1;
}
for(int i = 0;i< n;i++)
{
cout<<rel[i].second<<" ";
}
cout<<"\n";
}
}
}