The following solution to the problem “DPAIRS” is throwing an error “SIGFPE” on codechef IDE. kindly help me out…
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n=0, m=0;
cin>>n>>m;
int a[n]={ } , b[m]={ };
for (register size_t i = 0; i < n; i++) cin>>a[i];
for (register size_t i = 0; i < m; i++) cin>>b[i];
set distinctSum;
while(distinctSum.size()!=n+m-1){
int x=rand()%n;
int y=rand()%m;
try{pair<set::iterator , bool> check = distinctSum.insert(a[x]+b[y]);
if(check.second==true)
cout<<x<<" "<<y<<endl;
}catch(std::out_of_range &e){
cout<<e.what();
}
catch(…){
cout<<“Undefined Exception!!”;
}
}
return 0;
}