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

Автор practice_has, история, 3 месяца назад, По-английски

Hi everyone, I’m having trouble understanding the editorial for the problem Speedbreaker, and I haven’t been able to find a clear explanation, either in the comments under the editorial or on YouTube. Could someone explain the approach in detail for a beginner like me? I don’t understand how city i, after being chosen as a starting city, can be verified as a valid starting city. How do you check or confirm this? What is the method for selecting the next set of adjacent cities, and in what order should this be done? Is it done greedily, or is there a particular strategy involved? Please explain everything from scratch. Additionally, how can the range of cities from l = max(l, i — a[i] + 1) to r = min(r, i + a[i] — 1) be considered valid starting cities? The editorial seems too straightforward, and I’m having difficulty understanding the underlying intuition. I’ve spent a day on this but still can’t figure it out. Could someone please explain the approach in a way I can understand? It would be a huge help!

Полный текст и комментарии »

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

Автор practice_has, история, 5 месяцев назад, По-английски

I was learning about interactive problems, and I solved a few problems such as:

1. Guess the Number

E. Interview

I also read this blog:

Interactive Problems: Guide for Participants

I learned that you have to use either endl or cout.flush() after "\n".

However, I tried not using cout.flush() at all and just used "\n" or endl.

Now, endl works because it includes the flush operation, but why is "\n" working without cout.flush()?

Are interactive problems only interactive during live contests?

Can someone please try solving the above two problems with "\n" and no cout.flush() and explain this behavior to me?

Here are my solutions with "\n" only:

1. Guess the Number

E. Interview

Полный текст и комментарии »

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

Автор practice_has, история, 12 месяцев назад, По-английски

Can someone tell me what is the difference in logic between the two solutions?

The first solution is accepted by the CSES

Code 1

The second solution is giving TLE

Code 2

The only difference in code is the order of nested for loop

Someone please help!

Полный текст и комментарии »

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