# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | 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 | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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.