# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
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.