# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Name |
---|
add these 2 magic lines:
ios::sync_with_stdio(false); cin.tie(0);
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?
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 andstd::cout
-style streams everything will still be read and printed in the correct order.However, if you're sure your program only uses
cin
andcout
you can turn off this synchronization withios::sync_with_stdio(false)
and make input considerably faster.You said "identical" it's not.
ios::sync_with_stdio(false); cin.tie(0);
Also you need to be careful with "endl" too.
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.
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.
the thing is, he isn't trash-posting...
...
1.)ios::sync_with_stdio(false); cin.tie(0);
use this for fast input output2.)Avoid using "endl" instead using "\n";
3.) never underestimate a newbie
or
Lmao, agree with the first 2
Just was curious about the last line. Why should we avoid endl?
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.
Never underestimate a specialist
Unless you're Umnik
Agree with the third
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
Why he got downvotes, I think there's nothing wrong.