rgnerdplayer's blog

By rgnerdplayer, history, 3 years ago, In English

I was just doing virtual on 1338A - Прибавление степеней.

I wrote the following code: 121160133

and it out puts "63" on this test: N = 5, A = {-9, -2, -2, 7, 5} on both versions of C++17.

The probably problematic part is here:

code

If I output i and ans, ans is changed to 63 at i = 2.

But I thought __lg(0) is -1? Also in custom invocation, the error message never appears, and the code is never terminated by assert(false).

Does anyone have any idea?

Full text and comments »

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

By rgnerdplayer, 4 years ago, In English

For data structures such as persistent segment tree or treaps, is it OK if I submit a solution that DOESN'T delete the pointers I used? Also, is there any method more convenient than recursively delete all the trees at the end of my program?

Full text and comments »

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