So I have this code in which I print lower, upper, and equal range but IDK how to print equal range if someone knows how I will like a coded solution to be submitted thanks
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vi;
typedef pair<long long,long long> pi;
typedef vector<pi> vpi;
#define FOR(i, a, b) for(ll i=ll(a); i<ll(b); i++)
#define ROF(i, a, b) for(ll i=ll(a); i>=ll(b); i--)
#define f first
#define s second
#define pb emplace_back
#define mp make_pair
#define SQ(a) (a)*(a)
#define all(a) (a).begin(), (a).end()
int main() {
ll n,x=6,s;
cin>>n;
vi ar;
FOR(i,0,n)cin>>s; ar.pb(s);
auto a = lower_bound(all(ar), x)-ar.begin();
auto b = upper_bound(all(ar), x)-ar.begin();
auto c = equal_range(all(ar), x);
cout<<"lower_bound "<<a<<' '<<"upper_bound"<<' '<<b<<' '<<"equal range.first"<<' '<<c.f<< ' '<<"equal range.second"<<' '<<c.s<<"\n";
return 0;
}
If I have understood correctly then what you mean is the following
Pay attention to that instead of expressions like for example this
it is better to use the standard function
std::distance
declared in the header<iterator>
. For exampleBear in mind that it is a bad style of programming to introduce macros that hides well-known standard constructions and identifiers.