Tparsa's blog

By Tparsa, 10 years ago, In English

Hello!

I have problem with this problem (:D !!) here is my submission

Thanks for your attention!

GOOD BYE !

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

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

Try changing from cin to scanf. It's a pretty big input, so maybe the issue lies there.

UPDATE: Indeed, changing to scanf gets it AC.

»
10 years ago, # |
  Vote: I like it +13 Vote: I do not like it

And as a side note, I saw in your code that you do (int)ceil( L[parV] / 2.0 ), when you could have simply done (L[parV] + 1) / 2. Without loss of generality, whenever you want to do ceil(a/b), it's more convenient to code (a+b-1)/b.

I know this has nothing to do with your original question, I just wanted to comment that.

»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it

cin.tie(0) might also help. I actually thought that it would be almost as fast as scanf but doesnt seem to be the case and it is not enough to get AC. However, endl is very slow and with cin.tie(0) and '\n' you can also get AC. With scanf and '\n' or printf it is even faster.

Is there some difference between ios_base::sync_with_stdio(0) and ios::sync_with_stdio(0)?