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

Автор _Ramtin_, история, 11 лет назад, По-английски

Hi everyone , I have a question which i faced a lot while implementing a problem and i usually handled it with segment tree but i think it must have an easier way

think that u have a set s

i want to find out number x position in this set

more formally i want s.find(x) — s.begin()

but c++ set can't handle this ! what should i do ? is there any way without using other structures to solve this ?

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

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by _Ramtin_ (previous revision, new revision, compare).

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится
»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

If there are many such 'queries', then transform std::set into a vector. Vector supports upper_bound/lower_bound functions and by subtracting v.begin() you can get the index.

»
11 лет назад, скрыть # |
 
Проголосовать: нравится -6 Проголосовать: не нравится

Your Big Problem is your little penis!