practice_has's blog

By practice_has, history, 3 months ago, In English

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!

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By practice_has, history, 5 months ago, In English

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

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

By practice_has, history, 12 months ago, In English

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!

Full text and comments »

  • Vote: I like it
  • -6
  • Vote: I do not like it