#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using
namespace
__gnu_pbds;
using
namespace
std;
typedef
tree<pair<
int
,
int
>, null_type, less<pair<
int
,
int
> >,
rb_tree_tag, tree_order_statistics_node_update>
ordered_map;
int
main()
{
ordered_map om;
om.insert({ 23, 20 });
om.insert({ 23, 10 });
om.insert({ 23, 30 });
om.insert({ 12, 35 });
om.insert({ 12, 22 });
cout <<
"Contents of map:\n"
;
cout <<
"KEY\tELEMENT\n"
;
for
(
auto
itr = om.begin(); itr != om.end(); ++itr) {
cout << itr->first <<
"\t"
<< itr->second <<
"\n"
;
}
cout <<
"The value at 3rd index is "
<<
"{"
<< om.find_by_order(3)->first <<
", "
<< om.find_by_order(3)->second <<
"}\n"
;
cout <<
"The index of pair {23, 30} is "
<< om.order_of_key({ 23, 30 }) << endl;
cout <<
"The index of pair {23, 40} is "
<< om.order_of_key({ 23, 40 }) << endl;
return
0;
}