Riaru_Covece's blog

By Riaru_Covece, history, 5 weeks 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

»
5 weeks 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);

  • »
    »
    5 weeks 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?

    • »
      »
      »
      5 weeks 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.

»
5 weeks 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.

»
5 weeks 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.

  • »
    »
    5 weeks 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.

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it
Points to remember
  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it -22 Vote: I do not like it

    or

    #define endl '\n'
    
  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +32 Vote: I do not like it

    Lmao, agree with the first 2

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Just was curious about the last line. Why should we avoid endl?

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      if you are using endl more than 1e4 time, then you should use "\n" instead , since endl is slower, as it also flush the output.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it -16 Vote: I do not like it

    Never underestimate a specialist

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Unless you're Umnik

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Stop flexing your new colour which you obtained by luck and isn't even worthy of any brag.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it -7 Vote: I do not like it

        Cyan isn't my new color and I find no meaning in showing it off.What I have achieved so far in cf isn't even 10% of my potential and it didn't happen by luck.So shut your mouth up and do some work.I will become red very soon and brag that day.Till then keep hating me.

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it +2 Vote: I do not like it

          You were confident of becoming expert in the contest after becoming specialist but you became newbie instead haha noob. Stop being cocky and so conceited of your worth ("specialist" after 80+ contests is no achievement and is in act wayyy below par for that many contests).

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

            Do you know when a sportsman goes to next level??When some idiot in the crowd shouts and the sportsman doesn't give a fuck

            Actually it is the first tip of emotional intelligence

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it -9 Vote: I do not like it

    Agree with the third

»
5 weeks 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