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

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

I was looking at the Josephus Problem II in the CSES problem set, and couldn't find a c++ solution that didn't use ordered_set, which is not in the standard library. This made me wonder if I need to learn about other libraries to get good at cp. Any input appreciated.

Also if someone knows how to solve the Josephus Problem II only using the standard library please outline it for me ty

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

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

my code here.

You essentially brute force the algorithm by finding the next person by literally locating the k'th person to the right.

The ordered set is needed in some solutions for querying "kth largest in a set of integers". Such queries can also be done by walking on segtrees as well.

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

I have solved it using binary search & BIT.

code