unable to find error in my code,it is showing segmention fault.
here is my code
#include<bits/stdc++.h>
using namespace std;
int main() {
int t,n,act=0;
vector<pair<int,int>> v;
v.reserve(10000);
cin>>t;
for(int i=0;i<t;i++)
{ cin>>n;
for(int i=0;i<n;i++)
{
int x,y;
cin>>x>>y;
v.push_back(make_pair(x,y));
}
for(auto it=v.begin();it!=v.end();it++)
{
int m;
m=it->second;
for(auto it2=it++;it2!=v.end();it2++)
{
if(m==(it2->first))
{ act++;}
}
}
}
cout<<act;
return 0;
}
Activity selection problem
You need to sort the activities on the basis of ending time.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
why is it showing segmentation fault