Блог пользователя ollpu

Автор ollpu, история, 3 года назад, По-английски

Just leaving this here:

auto q = priority_queue(greater(), vector{pair{0ll, 0}});
// or
auto q = priority_queue(greater(), vector{tuple{0ll, 0, 0}});

Only works in GCC 9.1 and up, so you have to submit as GCC C++17 64bit in Codeforces.

  • Проголосовать: нравится
  • +52
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

I like to write:

template<class T>
using pqt = priority_queue<T,vector<T>,greater<T>>

...

pqt<tuple<int,int,int>> q;

Its a bit longer than your option but you dont need to worry about the compiler version. Alternatively you can just use negative values to order correctly in the priority queue, but I dont like that either

»
3 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится
template<class T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<class T> using maxpq = priority_queue<T, vector<T>>;
template<class A, class B> using pq = priority_queue<A, vector<A>, B>;
»
3 года назад, # |
Rev. 2   Проголосовать: нравится +34 Проголосовать: не нравится

not related, but my friend likes to write

#define benq queue
#define pbenq priority_queue

:D

»
3 года назад, # |
Rev. 2   Проголосовать: нравится +6 Проголосовать: не нравится

Why bother?..

set<pair<int, int>> q = {{0ll, 0}};
// or
set<tuple<int, int, int>> q = {{0LL, 0, 0}};