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

Автор Vladosiya, история, 5 часов назад, перевод, По-русски

2000A - Первостепенная задача

Идея: senjougaharin

Разбор
Решение

2000B - Рассадка в автобусе

Идея: myav

Разбор
Решение

2000C - Числовой шаблон строки

Идея: myav

Разбор
Решение

2000D - Right Left Wrong

Идея: Vladosiya

Разбор
Решение

2000E - Фотосессия для горилл

Идея: Vladosiya

Разбор
Решение

2000F - Закрась строки и столбцы

Идея: senjougaharin

Разбор
Решение

2000G - Звонок во время пути

Идея: senjougaharin

Разбор
Решение

2000H - Ксюша и загруженное множество

Идея: senjougaharin

Разбор
Решение
  • Проголосовать: нравится
  • +24
  • Проголосовать: не нравится

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

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

Code

And also the issue with the algo pls.

  • »
    »
    4 часа назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

    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

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

      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

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

        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

        • »
          »
          »
          »
          »
          4 часа назад, # ^ |
          Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

          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

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

      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 :) .

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

    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.

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

      I did that that in the updated code here ->

      Code

      But this still gives me runtime error

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

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...

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

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

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

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. )

»
104 минуты назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

for E, I completely missed the n*m<=2e5 bound and coded a O(nlogn + mlogm + wlog(n*m)) solution

276188663

  • »
    »
    78 минут назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    I also misread the n*m<=2e5 constraint, and I tried to code a bfs type solution starting from the center of the grid where we greedily visit cells in the graph that have the most subarrays containing them. I failed in the implementation, but is your solution idea similar?

  • »
    »
    70 минут назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I got scared when I didn't see the n*m <= 2e5 condition and I immediately re-checked the problem statement :)

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

H can be solved using segment tree. 276462150