Riaru_Covece's blog

By Riaru_Covece, history, 3 years ago, In English

Here is the link to my submission: link and here is the link to Tourist's submission: link

I am new to CF, or if there's a better way to ask my questions or if I am violating any rules please do let me know.

  • Vote: I like it
  • +78
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +9 Vote: I do not like it

add these 2 magic lines:

ios::sync_with_stdio(false); cin.tie(0);

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

    Okay, sorry I had never heard of these functions before.

    I tried to read about it here:link

    My understanding is that the ios::sync line is needed to synchronize the outputs when we use both cout of C++ and print() of C but I have only used C++ then why should I use that line?

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +60 Vote: I do not like it

      My understanding is that the ios::sync line is needed to synchronize the outputs when we use both cout of C++ and print() of C

      No, it's the opposite.

      By default, the C++ streams have some complicated and relatively time-expensive logic to make sure that if you mix printf-style and std::cout-style streams everything will still be read and printed in the correct order.

      However, if you're sure your program only uses cin and cout you can turn off this synchronization with ios::sync_with_stdio(false) and make input considerably faster.

»
3 years ago, # |
  Vote: I like it +15 Vote: I do not like it

You said "identical" it's not.

ios::sync_with_stdio(false); cin.tie(0);

Also you need to be careful with "endl" too.

»
3 years ago, # |
Rev. 2   Vote: I like it +40 Vote: I do not like it

He is new in cf. why some people are downvoting his post? I think we should appreciate him at the beginning and help him to find out his mistake.

  • »
    »
    3 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    Downvotes can teach as well.When I opened my account I also shitposted and I got a lot of downvotes.I got very angry that day but now I understand why it was downvoted.

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +9 Vote: I do not like it

      the thing is, he isn't trash-posting...

»
3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it
Points to remember
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

if input of a problem contains number <= 10^18, u should use ios::sync_with_stdio(false); cin.tie(0);. It will be much faster

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Why he got downvotes, I think there's nothing wrong.