EJam's blog

By EJam, history, 2 years ago, In English

I'm revisiting CSES problem set to help a friend. In "Sorting and Searching", there is this problem: Josephus Problem II. My solution was using an ordered set, and after a quick search, it seems like everyone online did this too. However, we see the more general version of this problem: List Removals in the section "Range Queries".

The category of this problem and a solution which is more general made me wonder if there is an alternative solution, perhaps without ordered set. I did some search online and found O(n) solution to the Josephus Problem (also see cp-algorithm). But this is different from the CSES problem, as it only finds the last element.

So, out of curiosity, is there any solution that is not doing removal on ordered set? Otherwise, this feels like a pretty bad problem.

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By EJam, history, 4 years ago, In English

So I came up with an O(26nm) sol on 1393D - Рарити и новое платье which I think a few contestants (including me) didn't pass. Then I change vectors to arrays with memset and passed with 997 ms, which I don't think should be allowed.

Here are my submissions: 89275790 89299497

What's your thought? Should constraints be more obvious (change constant of 26, increase time limit)?

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it