Vladosiya's blog

By Vladosiya, history, 2 hours ago, In English

2000A - Primary Task

Idea: senjougaharin

Tutorial
Solution

2000B - Seating in a Bus

Idea: myav

Tutorial
Solution

2000C - Numeric String Template

Idea: myav

Tutorial
Solution

2000D - Right Left Wrong

Idea: Vladosiya

Tutorial
Solution

2000E - Photoshoot for Gorillas

Idea: Vladosiya

Tutorial
Solution

2000F - Color Rows and Columns

Idea: senjougaharin

Tutorial
Solution

2000G - Call During the Journey

Idea: senjougaharin

Tutorial
Solution

2000H - Ksyusha and the Loaded Set

Idea: senjougaharin

Tutorial
Solution
  • Vote: I like it
  • +17
  • Vote: I do not like it

»
94 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

can anyone pls tell why this code is getting a runtime error. for Problem D

Code

And also the issue with the algo pls.

  • »
    »
    89 minutes ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    consider the case where there are no 'R' in the string. in this scenario, your 'right' variable would be initialized with the value -1

    edit : avoid using C++17 (GCC 7-32) and use C++20 (GCC 13-64) instead

    • »
      »
      »
      80 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      you mean something like this -> n = 6, a(n) = 1 1 1 1 1 1 s = LLLLLL -> and the output should be 0 right. actually I checked this one already and it gives me 0 perfectly fine. Cause I'm checking the out of bound condition before using those

      • »
        »
        »
        »
        69 minutes ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I admit I do not know much about C++17 (32-bit), but if I had to guess, this particular error might be occurring because your while loop condition:

        while(left < leftsig.size() && right >= 0 && leftsig[left] < rightsig[right]) {

        is not stopping after right >= 0 evaluates to false. Instead, it continues evaluating leftsig[left] < rightsig[right], which could cause an access violation if right is -1 and thus result in the error

        you can fix it by choosing C++20 (GCC 13-64) as your compiler when you submit the code

        https://mirror.codeforces.com/contest/2000/submission/276452095

        • »
          »
          »
          »
          »
          64 minutes ago, # ^ |
          Rev. 2   Vote: I like it 0 Vote: I do not like it

          yeah I guess C++17 doesn't stop when a condition is false in the loop conditions, untill it checks all the conditions

          edit: I used the prefix sum to avoid tle and it went ohk

    • »
      »
      »
      67 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      oh thanks for the help it went perfectly just by changing this. Wasn't expecting it to be this sort of issue, will use C++ 20 always :) .

  • »
    »
    85 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    This solution will give tle as you are calculating sum of subarray again and again. Instead use prefix sum to get the sum of the subarray.

    • »
      »
      »
      74 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I did that that in the updated code here ->

      Code

      But this still gives me runtime error

»
53 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

I need help

Can anyone tell me why my solution in proplem E got TLE when i write it in java , but when i write the same code in c++ i got AC

java solution --> Your text to link here...

c++ solution --> Your text to link here...

»
49 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

someone explain how to intuit the way they count it in problem E please.

»
21 minute(s) ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

I am impressed by how treap is being casually used in a div3 contest editorial (problem H).

(Context: Of course I am well aware that this is not how most contestants solved, or are supposed to solve it, but rather make use of the (non-essential) constraints max <= 2e6. It is also clear that a fully online solution of this without the extra constraints will have to involve your favourite BBST. Though, I don't know how many people will get confused by the editorial. )

  • »
    »
    11 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    They took the effort to explain the std::set part but not the treap part :)