I want to change the elements of a set while comparing, like this :-
#include<bits/stdc++.h>
using namespace std;
struct cmp
{
bool operator()( pair<int,int> a, pair<int,int> b)
{
if(a.first<=b.first)
{
b.first++;
}
return a.first<b.first;
}
};
signed main()
{
int n;
cin>>n;
set< pair<int,int> ,cmp> s;
int position;
for(int i=0;i<n;i++)
{
cin>>position;
s.insert({position,i});
}
return 0;
}
However it is not working , can you tell me how can i do this??