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

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

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, история, 9 месяцев назад, По-английски

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
  • Проголосовать: не нравится